diff options
author | Oliver Neukum <oliver@neukum.org> | 2008-07-26 16:42:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-26 23:40:09 -0400 |
commit | 852fef69c0d9510a28a70221cfddd004efa02552 (patch) | |
tree | 3cc5a175ad181262926f0498a74054e482220088 /drivers/usb/serial/ipaq.c | |
parent | 9ee08c2df47c10ba624ff05a6c0f2500748bcb69 (diff) |
fix for a memory leak in an error case introduced by fix for double free
The fix NULLed a pointer without freeing it.
Signed-off-by: Oliver Neukum <oneukum@suse.de>
Reported-by: Juha Motorsportcom <juha_motorsportcom@luukku.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/ipaq.c')
-rw-r--r-- | drivers/usb/serial/ipaq.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 832a5a4f3cb3..cd9a2e138c8b 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -651,15 +651,17 @@ static int ipaq_open(struct tty_struct *tty, | |||
651 | */ | 651 | */ |
652 | 652 | ||
653 | kfree(port->bulk_in_buffer); | 653 | kfree(port->bulk_in_buffer); |
654 | kfree(port->bulk_out_buffer); | ||
655 | /* make sure the generic serial code knows */ | ||
656 | port->bulk_out_buffer = NULL; | ||
657 | |||
654 | port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); | 658 | port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); |
655 | if (port->bulk_in_buffer == NULL) { | 659 | if (port->bulk_in_buffer == NULL) |
656 | port->bulk_out_buffer = NULL; /* prevent double free */ | ||
657 | goto enomem; | 660 | goto enomem; |
658 | } | ||
659 | 661 | ||
660 | kfree(port->bulk_out_buffer); | ||
661 | port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); | 662 | port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL); |
662 | if (port->bulk_out_buffer == NULL) { | 663 | if (port->bulk_out_buffer == NULL) { |
664 | /* the buffer is useless, free it */ | ||
663 | kfree(port->bulk_in_buffer); | 665 | kfree(port->bulk_in_buffer); |
664 | port->bulk_in_buffer = NULL; | 666 | port->bulk_in_buffer = NULL; |
665 | goto enomem; | 667 | goto enomem; |