[media] as102: fix leaks at failure paths in as102_usb_probe()
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Fri, 27 Dec 2013 21:18:39 +0000 (18:18 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 7 Jan 2014 10:55:58 +0000 (08:55 -0200)
Failure handling is incomplete in as102_usb_probe().
The patch implements proper resource deallocations.

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/staging/media/as102/as102_usb_drv.c

index 8759553decac8bc67caea13ea81139ed16179c9d..e4a69454ebeb5f862ad73399e6a5969b8d08782b 100644 (file)
@@ -401,14 +401,21 @@ static int as102_usb_probe(struct usb_interface *intf,
        /* request buffer allocation for streaming */
        ret = as102_alloc_usb_stream_buffer(as102_dev);
        if (ret != 0)
-               goto failed;
+               goto failed_stream;
 
        /* register dvb layer */
        ret = as102_dvb_register(as102_dev);
+       if (ret != 0)
+               goto failed_dvb;
 
        return ret;
 
+failed_dvb:
+       as102_free_usb_stream_buffer(as102_dev);
+failed_stream:
+       usb_deregister_dev(intf, &as102_usb_class_driver);
 failed:
+       usb_put_dev(as102_dev->bus_adap.usb_dev);
        usb_set_intfdata(intf, NULL);
        kfree(as102_dev);
        return ret;