ALSA: firewire: fix a memory leak bug
PATCH 1/1 ALSA: firewire: fix a memory leak bug
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.
--- sound/firewire/packets-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/firewire/packets-buffer.c +1 -1
@@ -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);
Signature · 1 line
2.7.4
Hi,
Quoted 6 lines · Wenwen Wang
In
iso_packets_buffer_init(), 'b->packets' is allocated throughkmalloc_array(). Then, the aligned packet size is checked. If it is larger thanPAGE_SIZE,-EINVALwill be returned to indicate the error. However, the allocated 'b->packets' is not deallocated on this path, leading to a memory leak.
Quoted 6 lines
To fix the above issue, free '
b->packets' before returning the error code.Signed-off-by Wenwen Wang <[email protected]>--- sound/firewire/packets-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
And this bug exists till its first commit for v2.6.39.
Thanks
Takashi Sakamoto
Takashi Iwai
AppliedQuoted 17 lines · Takashi Sakamoto
Hi,
Quoted 6 lines · Wenwen Wang
In
iso_packets_buffer_init(), 'b->packets' is allocated throughkmalloc_array(). Then, the aligned packet size is checked. If it is larger thanPAGE_SIZE,-EINVALwill be returned to indicate the error. However, the allocated 'b->packets' is not deallocated on this path, leading to a memory leak.Quoted 6 lines
To fix the above issue, free '
b->packets' before returning the error code.Signed-off-by Wenwen Wang <[email protected]>--- sound/firewire/packets-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 6 lines
Reviewed-by Takashi Sakamoto <[email protected]>And this bug exists till its first commit for v2.6.39.
Fixes 31ef9134eb52 ("ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver")Cc <[email protected]> # v2.6.39+
Applied, thanks.
Takashi