[media] tlg2300: implement error handling in poseidon_probe()
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Mon, 24 Jun 2013 18:57:36 +0000 (15:57 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 26 Jul 2013 16:27:12 +0000 (13:27 -0300)
All poseidon init functions properly return error codes,
but they are ignored by poseidon_probe(). The patch implements
handling of error cases.
Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/usb/tlg2300/pd-main.c

index e07e4c699cc215344b86f10433f659a088617d00..ca5e1bc99d8da7604056b4d37fbe41d7240bf975 100644 (file)
@@ -436,12 +436,22 @@ static int poseidon_probe(struct usb_interface *interface,
 
                /* register v4l2 device */
                ret = v4l2_device_register(&interface->dev, &pd->v4l2_dev);
+               if (ret)
+                       goto err_v4l2;
 
                /* register devices in directory /dev */
                ret = pd_video_init(pd);
-               poseidon_audio_init(pd);
-               poseidon_fm_init(pd);
-               pd_dvb_usb_device_init(pd);
+               if (ret)
+                       goto err_video;
+               ret = poseidon_audio_init(pd);
+               if (ret)
+                       goto err_audio;
+               ret = poseidon_fm_init(pd);
+               if (ret)
+                       goto err_fm;
+               ret = pd_dvb_usb_device_init(pd);
+               if (ret)
+                       goto err_dvb;
 
                INIT_LIST_HEAD(&pd->device_list);
                list_add_tail(&pd->device_list, &pd_device_list);
@@ -459,6 +469,17 @@ static int poseidon_probe(struct usb_interface *interface,
        }
 #endif
        return 0;
+err_dvb:
+       poseidon_fm_exit(pd);
+err_fm:
+       poseidon_audio_free(pd);
+err_audio:
+       pd_video_exit(pd);
+err_video:
+       v4l2_device_unregister(&pd->v4l2_dev);
+err_v4l2:
+       kfree(pd);
+       return ret;
 }
 
 static void poseidon_disconnect(struct usb_interface *interface)