Skip to content

Commit

Permalink
USB: fix double kfree in ipaq in error case
Browse files Browse the repository at this point in the history
in the error case the ipaq driver leaves a dangling pointer to already
freed memory that will be freed again.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Jul 21, 2008
1 parent 3575858 commit df3e1ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/usb/serial/ipaq.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
*/

kfree(port->bulk_in_buffer);
kfree(port->bulk_out_buffer);
port->bulk_in_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL);
if (port->bulk_in_buffer == NULL) {
port->bulk_out_buffer = NULL; /* prevent double free */
goto enomem;
}

kfree(port->bulk_out_buffer);
port->bulk_out_buffer = kmalloc(URBDATA_SIZE, GFP_KERNEL);
if (port->bulk_out_buffer == NULL) {
kfree(port->bulk_in_buffer);
Expand Down

0 comments on commit df3e1ab

Please sign in to comment.