Skip to content

Commit

Permalink
USB: serial: garmin_gps: fix memory leak on probe errors
Browse files Browse the repository at this point in the history
Make sure to free the port private data before returning after a failed
probe attempt.

Fixes: 1da177e ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
  • Loading branch information
Johan Hovold committed Oct 11, 2017
1 parent 19a565d commit 74d471b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/usb/serial/garmin_gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,12 @@ static int garmin_port_probe(struct usb_serial_port *port)
usb_set_serial_port_data(port, garmin_data_p);

status = garmin_init_session(port);
if (status)
goto err_free;

return 0;
err_free:
kfree(garmin_data_p);

return status;
}
Expand Down

0 comments on commit 74d471b

Please sign in to comment.