Skip to content

Commit 7dc53ee

Browse files
ArvindYadavCsBrian Maly
authored andcommitted
media: hdpvr: Fix an error handling path in hdpvr_probe()
commit c0f71bb 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: Arvind Yadav <[email protected]> Reported-by: Andrey Konovalov <[email protected]> Tested-by: Andrey Konovalov <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> Cc: Ben Hutchings <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Orabug: 31352053 CVE: CVE-2017-16644 (cherry picked from commit 198a7ddaf5d2c76130b28f19ed6d768860ea2b8e) Signed-off-by: Dan Duval <[email protected]> Reviewed-by: Jack Vogel <[email protected]> Conflict: drivers/media/usb/hdpvr/hdpvr-core.c Signed-off-by: Brian Maly <[email protected]>
1 parent ee7eb12 commit 7dc53ee

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/media/usb/hdpvr/hdpvr-core.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static int hdpvr_probe(struct usb_interface *interface,
293293
/* register v4l2_device early so it can be used for printks */
294294
if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) {
295295
dev_err(&interface->dev, "v4l2_device_register failed\n");
296-
goto error;
296+
goto error_free_dev;
297297
}
298298

299299
mutex_init(&dev->io_mutex);
@@ -302,7 +302,7 @@ static int hdpvr_probe(struct usb_interface *interface,
302302
dev->usbc_buf = kmalloc(64, GFP_KERNEL);
303303
if (!dev->usbc_buf) {
304304
v4l2_err(&dev->v4l2_dev, "Out of memory\n");
305-
goto error;
305+
goto error_v4l2_unregister;
306306
}
307307

308308
init_waitqueue_head(&dev->wait_buffer);
@@ -344,29 +344,29 @@ static int hdpvr_probe(struct usb_interface *interface,
344344
}
345345
if (!dev->bulk_in_endpointAddr) {
346346
v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n");
347-
goto error;
347+
goto error_put_usb;
348348
}
349349

350350
/* init the device */
351351
if (hdpvr_device_init(dev)) {
352352
v4l2_err(&dev->v4l2_dev, "device init failed\n");
353-
goto error;
353+
goto error_put_usb;
354354
}
355355

356356
mutex_lock(&dev->io_mutex);
357357
if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) {
358358
mutex_unlock(&dev->io_mutex);
359359
v4l2_err(&dev->v4l2_dev,
360360
"allocating transfer buffers failed\n");
361-
goto error;
361+
goto error_put_usb;
362362
}
363363
mutex_unlock(&dev->io_mutex);
364364

365365
#if IS_ENABLED(CONFIG_I2C)
366366
retval = hdpvr_register_i2c_adapter(dev);
367367
if (retval < 0) {
368368
v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n");
369-
goto error;
369+
goto error_free_buffers;
370370
}
371371

372372
client = hdpvr_register_ir_rx_i2c(dev);
@@ -399,15 +399,17 @@ static int hdpvr_probe(struct usb_interface *interface,
399399
reg_fail:
400400
#if IS_ENABLED(CONFIG_I2C)
401401
i2c_del_adapter(&dev->i2c_adapter);
402+
error_free_buffers:
402403
#endif
404+
hdpvr_free_buffers(dev);
405+
error_put_usb:
406+
usb_put_dev(dev->udev);
407+
kfree(dev->usbc_buf);
408+
error_v4l2_unregister:
409+
v4l2_device_unregister(&dev->v4l2_dev);
410+
error_free_dev:
411+
kfree(dev);
403412
error:
404-
if (dev) {
405-
/* Destroy single thread */
406-
if (dev->workqueue)
407-
destroy_workqueue(dev->workqueue);
408-
/* this frees allocated memory */
409-
hdpvr_delete(dev);
410-
}
411413
return retval;
412414
}
413415

0 commit comments

Comments
 (0)