USB: serial: garmin_gps: fix memory leak on probe errors

commit 74d471b598 upstream.

Make sure to free the port private data before returning after a failed
probe attempt.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
This commit is contained in:
Johan Hovold 2017-10-11 14:02:58 +02:00 committed by Ben Hutchings
parent 5a41add5d4
commit c04c343f48

View File

@ -1476,6 +1476,12 @@ static int garmin_attach(struct usb_serial *serial)
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;
}