uwb: hwa-rc: fix memory leak at probe
authorAnton Vasilyev <vasilyev@ispras.ru>
Fri, 6 Jul 2018 12:32:53 +0000 (15:32 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Oct 2018 00:01:42 +0000 (17:01 -0700)
[ Upstream commit 11b71782c1d10d9bccc31825cf84291cd7588a1e ]

hwarc_probe() allocates memory for hwarc, but does not free it
if uwb_rc_add() or hwarc_get_version() fail.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/uwb/hwa-rc.c

index 9a53912..5d3ba74 100644 (file)
@@ -873,6 +873,7 @@ error_get_version:
 error_rc_add:
        usb_put_intf(iface);
        usb_put_dev(hwarc->usb_dev);
+       kfree(hwarc);
 error_alloc:
        uwb_rc_put(uwb_rc);
 error_rc_alloc: