Skip to contentSkip to conversation

ALSA: firewire: fix a memory leak bug

PATCH Applied Wenwen Wang 3 participants 3 messages Aug 8, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 0d35359..0ecafd0 100644
@@ -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
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 6 lines · Wenwen Wang

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.

Quoted 6 lines

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(-)

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+

Thanks

Takashi Sakamoto

Applied
#2 lore raw
Quoted 17 lines · Takashi Sakamoto

Hi,

Quoted 6 lines · Wenwen Wang

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.

Quoted 6 lines

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(-)
Quoted 6 lines

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