Commit 9f806795 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] usb: check media device errors

There are now two new warnings:

drivers/media/usb/dvb-usb-v2/dvb_usb_core.c: In function 'dvb_usbv2_media_device_register':
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:433:2: warning: ignoring return value of '__media_device_register', declared with attribute warn_unused_result [-Wunused-result]
  media_device_register(adap->dvb_adap.mdev);
  ^
drivers/media/usb/dvb-usb/dvb-usb-dvb.c: In function 'dvb_usb_media_device_register':
drivers/media/usb/dvb-usb/dvb-usb-dvb.c:128:2: warning: ignoring return value of '__media_device_register', declared with attribute warn_unused_result [-Wunused-result]
  media_device_register(adap->dvb_adap.mdev);
  ^

Those are because the drivers are not properly checking if the
media device init and register were succeeded.

Fix it.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 9832e155
...@@ -217,15 +217,15 @@ static void au0828_usb_disconnect(struct usb_interface *interface) ...@@ -217,15 +217,15 @@ static void au0828_usb_disconnect(struct usb_interface *interface)
au0828_usb_release(dev); au0828_usb_release(dev);
} }
static void au0828_media_device_init(struct au0828_dev *dev, static int au0828_media_device_init(struct au0828_dev *dev,
struct usb_device *udev) struct usb_device *udev)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev; struct media_device *mdev;
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev) if (!mdev)
return; return -ENOMEM;
mdev->dev = &udev->dev; mdev->dev = &udev->dev;
...@@ -243,6 +243,7 @@ static void au0828_media_device_init(struct au0828_dev *dev, ...@@ -243,6 +243,7 @@ static void au0828_media_device_init(struct au0828_dev *dev,
dev->media_dev = mdev; dev->media_dev = mdev;
#endif #endif
return 0;
} }
...@@ -368,7 +369,14 @@ static int au0828_usb_probe(struct usb_interface *interface, ...@@ -368,7 +369,14 @@ static int au0828_usb_probe(struct usb_interface *interface,
dev->board = au0828_boards[dev->boardnr]; dev->board = au0828_boards[dev->boardnr];
/* Initialize the media controller */ /* Initialize the media controller */
au0828_media_device_init(dev, usbdev); retval = au0828_media_device_init(dev, usbdev);
if (retval) {
pr_err("%s() au0828_media_device_init failed\n",
__func__);
mutex_unlock(&dev->lock);
kfree(dev);
return retval;
}
#ifdef CONFIG_VIDEO_AU0828_V4L2 #ifdef CONFIG_VIDEO_AU0828_V4L2
dev->v4l2_dev.release = au0828_usb_v4l2_release; dev->v4l2_dev.release = au0828_usb_v4l2_release;
......
...@@ -1206,7 +1206,7 @@ void cx231xx_release_resources(struct cx231xx *dev) ...@@ -1206,7 +1206,7 @@ void cx231xx_release_resources(struct cx231xx *dev)
clear_bit(dev->devno, &cx231xx_devused); clear_bit(dev->devno, &cx231xx_devused);
} }
static void cx231xx_media_device_init(struct cx231xx *dev, static int cx231xx_media_device_init(struct cx231xx *dev,
struct usb_device *udev) struct usb_device *udev)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
...@@ -1214,7 +1214,7 @@ static void cx231xx_media_device_init(struct cx231xx *dev, ...@@ -1214,7 +1214,7 @@ static void cx231xx_media_device_init(struct cx231xx *dev,
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev) if (!mdev)
return; return -ENOMEM;
mdev->dev = dev->dev; mdev->dev = dev->dev;
strlcpy(mdev->model, dev->board.name, sizeof(mdev->model)); strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
...@@ -1228,6 +1228,7 @@ static void cx231xx_media_device_init(struct cx231xx *dev, ...@@ -1228,6 +1228,7 @@ static void cx231xx_media_device_init(struct cx231xx *dev,
dev->media_dev = mdev; dev->media_dev = mdev;
#endif #endif
return 0;
} }
static int cx231xx_create_media_graph(struct cx231xx *dev) static int cx231xx_create_media_graph(struct cx231xx *dev)
...@@ -1663,7 +1664,11 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1663,7 +1664,11 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
usb_set_intfdata(interface, dev); usb_set_intfdata(interface, dev);
/* Initialize the media controller */ /* Initialize the media controller */
cx231xx_media_device_init(dev, udev); retval = cx231xx_media_device_init(dev, udev);
if (retval) {
dev_err(d, "cx231xx_media_device_init failed\n");
goto err_media_init;
}
/* Create v4l2 device */ /* Create v4l2 device */
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
...@@ -1758,6 +1763,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1758,6 +1763,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
err_init: err_init:
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
err_v4l2: err_v4l2:
cx231xx_unregister_media_device(dev);
err_media_init:
usb_set_intfdata(interface, NULL); usb_set_intfdata(interface, NULL);
err_if: err_if:
usb_put_dev(udev); usb_put_dev(udev);
......
...@@ -400,7 +400,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) ...@@ -400,7 +400,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
return ret; return ret;
} }
static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) static int dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
struct media_device *mdev; struct media_device *mdev;
...@@ -409,7 +409,7 @@ static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) ...@@ -409,7 +409,7 @@ static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap)
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev) if (!mdev)
return; return -ENOMEM;
mdev->dev = &udev->dev; mdev->dev = &udev->dev;
strlcpy(mdev->model, d->name, sizeof(mdev->model)); strlcpy(mdev->model, d->name, sizeof(mdev->model));
...@@ -425,12 +425,15 @@ static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) ...@@ -425,12 +425,15 @@ static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap)
dev_info(&d->udev->dev, "media controller created\n"); dev_info(&d->udev->dev, "media controller created\n");
#endif #endif
return 0;
} }
static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap) static int dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
media_device_register(adap->dvb_adap.mdev); return media_device_register(adap->dvb_adap.mdev);
#else
return 0;
#endif #endif
} }
...@@ -466,7 +469,12 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -466,7 +469,12 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
adap->dvb_adap.priv = adap; adap->dvb_adap.priv = adap;
dvb_usbv2_media_device_init(adap); ret = dvb_usbv2_media_device_init(adap);
if (ret < 0) {
dev_dbg(&d->udev->dev, "%s: dvb_usbv2_media_device_init() failed=%d\n",
__func__, ret);
goto err_dvb_register_mc;
}
if (d->props->read_mac_address) { if (d->props->read_mac_address) {
ret = d->props->read_mac_address(adap, ret = d->props->read_mac_address(adap,
...@@ -517,6 +525,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -517,6 +525,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
dvb_dmx_release(&adap->demux); dvb_dmx_release(&adap->demux);
err_dvb_dmx_init: err_dvb_dmx_init:
dvb_usbv2_media_device_unregister(adap); dvb_usbv2_media_device_unregister(adap);
err_dvb_register_mc:
dvb_unregister_adapter(&adap->dvb_adap); dvb_unregister_adapter(&adap->dvb_adap);
err_dvb_register_adapter: err_dvb_register_adapter:
adap->dvb_adap.priv = NULL; adap->dvb_adap.priv = NULL;
...@@ -701,9 +710,9 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) ...@@ -701,9 +710,9 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
if (ret < 0) if (ret < 0)
goto err_dvb_unregister_frontend; goto err_dvb_unregister_frontend;
dvb_usbv2_media_device_register(adap); ret = dvb_usbv2_media_device_register(adap);
return 0; return ret;
err_dvb_unregister_frontend: err_dvb_unregister_frontend:
for (i = count_registered - 1; i >= 0; i--) for (i = count_registered - 1; i >= 0; i--)
......
...@@ -95,7 +95,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) ...@@ -95,7 +95,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
return dvb_usb_ctrl_feed(dvbdmxfeed, 0); return dvb_usb_ctrl_feed(dvbdmxfeed, 0);
} }
static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap) static int dvb_usb_media_device_init(struct dvb_usb_adapter *adap)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
struct media_device *mdev; struct media_device *mdev;
...@@ -104,7 +104,7 @@ static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap) ...@@ -104,7 +104,7 @@ static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap)
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev) if (!mdev)
return; return -ENOMEM;
mdev->dev = &udev->dev; mdev->dev = &udev->dev;
strlcpy(mdev->model, d->desc->name, sizeof(mdev->model)); strlcpy(mdev->model, d->desc->name, sizeof(mdev->model));
...@@ -120,12 +120,15 @@ static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap) ...@@ -120,12 +120,15 @@ static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap)
dev_info(&d->udev->dev, "media controller created\n"); dev_info(&d->udev->dev, "media controller created\n");
#endif #endif
return 0;
} }
static void dvb_usb_media_device_register(struct dvb_usb_adapter *adap) static int dvb_usb_media_device_register(struct dvb_usb_adapter *adap)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
media_device_register(adap->dvb_adap.mdev); return media_device_register(adap->dvb_adap.mdev);
#else
return 0;
#endif #endif
} }
...@@ -155,7 +158,11 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums) ...@@ -155,7 +158,11 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums)
} }
adap->dvb_adap.priv = adap; adap->dvb_adap.priv = adap;
dvb_usb_media_device_init(adap); ret = dvb_usb_media_device_init(adap);
if (ret < 0) {
deb_info("dvb_usb_media_device_init failed: error %d", ret);
goto err_mc;
}
if (adap->dev->props.read_mac_address) { if (adap->dev->props.read_mac_address) {
if (adap->dev->props.read_mac_address(adap->dev, adap->dvb_adap.proposed_mac) == 0) if (adap->dev->props.read_mac_address(adap->dev, adap->dvb_adap.proposed_mac) == 0)
...@@ -205,6 +212,7 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums) ...@@ -205,6 +212,7 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums)
dvb_dmx_release(&adap->demux); dvb_dmx_release(&adap->demux);
err_dmx: err_dmx:
dvb_usb_media_device_unregister(adap); dvb_usb_media_device_unregister(adap);
err_mc:
dvb_unregister_adapter(&adap->dvb_adap); dvb_unregister_adapter(&adap->dvb_adap);
err: err:
return ret; return ret;
...@@ -323,8 +331,10 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) ...@@ -323,8 +331,10 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
return ret; return ret;
ret = dvb_create_media_graph(&adap->dvb_adap); ret = dvb_create_media_graph(&adap->dvb_adap);
if (ret)
return ret;
dvb_usb_media_device_register(adap); ret = dvb_usb_media_device_register(adap);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment