Commit 198a7dda authored by Arvind Yadav's avatar Arvind Yadav Committed by Greg Kroah-Hartman

media: hdpvr: Fix an error handling path in hdpvr_probe()

commit c0f71bbb upstream.

Here, hdpvr_register_videodev() is responsible for setup and
register a video device. Also defining and initializing a worker.
hdpvr_register_videodev() is calling by hdpvr_probe at last.
So no need to flush any work here.
Unregister v4l2, free buffers and memory. If hdpvr_probe() will fail.
Signed-off-by: default avatarArvind Yadav <arvind.yadav.cs@gmail.com>
Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Tested-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f320dd20
...@@ -295,7 +295,7 @@ static int hdpvr_probe(struct usb_interface *interface, ...@@ -295,7 +295,7 @@ static int hdpvr_probe(struct usb_interface *interface,
/* register v4l2_device early so it can be used for printks */ /* register v4l2_device early so it can be used for printks */
if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) { if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) {
dev_err(&interface->dev, "v4l2_device_register failed\n"); dev_err(&interface->dev, "v4l2_device_register failed\n");
goto error; goto error_free_dev;
} }
mutex_init(&dev->io_mutex); mutex_init(&dev->io_mutex);
...@@ -304,7 +304,7 @@ static int hdpvr_probe(struct usb_interface *interface, ...@@ -304,7 +304,7 @@ static int hdpvr_probe(struct usb_interface *interface,
dev->usbc_buf = kmalloc(64, GFP_KERNEL); dev->usbc_buf = kmalloc(64, GFP_KERNEL);
if (!dev->usbc_buf) { if (!dev->usbc_buf) {
v4l2_err(&dev->v4l2_dev, "Out of memory\n"); v4l2_err(&dev->v4l2_dev, "Out of memory\n");
goto error; goto error_v4l2_unregister;
} }
init_waitqueue_head(&dev->wait_buffer); init_waitqueue_head(&dev->wait_buffer);
...@@ -342,13 +342,13 @@ static int hdpvr_probe(struct usb_interface *interface, ...@@ -342,13 +342,13 @@ static int hdpvr_probe(struct usb_interface *interface,
} }
if (!dev->bulk_in_endpointAddr) { if (!dev->bulk_in_endpointAddr) {
v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n"); v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n");
goto error; goto error_put_usb;
} }
/* init the device */ /* init the device */
if (hdpvr_device_init(dev)) { if (hdpvr_device_init(dev)) {
v4l2_err(&dev->v4l2_dev, "device init failed\n"); v4l2_err(&dev->v4l2_dev, "device init failed\n");
goto error; goto error_put_usb;
} }
mutex_lock(&dev->io_mutex); mutex_lock(&dev->io_mutex);
...@@ -356,7 +356,7 @@ static int hdpvr_probe(struct usb_interface *interface, ...@@ -356,7 +356,7 @@ static int hdpvr_probe(struct usb_interface *interface,
mutex_unlock(&dev->io_mutex); mutex_unlock(&dev->io_mutex);
v4l2_err(&dev->v4l2_dev, v4l2_err(&dev->v4l2_dev,
"allocating transfer buffers failed\n"); "allocating transfer buffers failed\n");
goto error; goto error_put_usb;
} }
mutex_unlock(&dev->io_mutex); mutex_unlock(&dev->io_mutex);
...@@ -364,7 +364,7 @@ static int hdpvr_probe(struct usb_interface *interface, ...@@ -364,7 +364,7 @@ static int hdpvr_probe(struct usb_interface *interface,
retval = hdpvr_register_i2c_adapter(dev); retval = hdpvr_register_i2c_adapter(dev);
if (retval < 0) { if (retval < 0) {
v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n"); v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n");
goto error; goto error_free_buffers;
} }
client = hdpvr_register_ir_rx_i2c(dev); client = hdpvr_register_ir_rx_i2c(dev);
...@@ -397,13 +397,17 @@ static int hdpvr_probe(struct usb_interface *interface, ...@@ -397,13 +397,17 @@ static int hdpvr_probe(struct usb_interface *interface,
reg_fail: reg_fail:
#if IS_ENABLED(CONFIG_I2C) #if IS_ENABLED(CONFIG_I2C)
i2c_del_adapter(&dev->i2c_adapter); i2c_del_adapter(&dev->i2c_adapter);
error_free_buffers:
#endif #endif
hdpvr_free_buffers(dev);
error_put_usb:
usb_put_dev(dev->udev);
kfree(dev->usbc_buf);
error_v4l2_unregister:
v4l2_device_unregister(&dev->v4l2_dev);
error_free_dev:
kfree(dev);
error: error:
if (dev) {
flush_work(&dev->worker);
/* this frees allocated memory */
hdpvr_delete(dev);
}
return retval; return retval;
} }
......
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