Skip to content

Commit

Permalink
ALSA: firewire: fix a memory leak bug
Browse files Browse the repository at this point in the history
In iso_packets_buffer_init(), 'b->packets' is allocated through
kmalloc_array(). Then, the aligned packet size is checked. If it is
larger than PAGE_SIZE, -EINVAL will be returned to indicate the error.
However, the allocated 'b->packets' is not deallocated on this path,
leading to a memory leak.

To fix the above issue, free 'b->packets' before returning the error code.

Fixes: 31ef913 ("ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver")
Signed-off-by: Wenwen Wang <[email protected]>
Reviewed-by: Takashi Sakamoto <[email protected]>
Cc: <[email protected]> # v2.6.39+
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
wenwenwang1 authored and tiwai committed Aug 8, 2019
1 parent c7cd7c7 commit 1be3c1f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/firewire/packets-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit,
packets_per_page = PAGE_SIZE / packet_size;
if (WARN_ON(!packets_per_page)) {
err = -EINVAL;
goto error;
goto err_packets;
}
pages = DIV_ROUND_UP(count, packets_per_page);

Expand Down

0 comments on commit 1be3c1f

Please sign in to comment.