mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
media: hdpvr: fix iteration over uninitialized lists in hdpvr_probe()
commit 2e923a0527
upstream.
free_buff_list and rec_buff_list are initialized in the middle of hdpvr_probe(),
but if something bad happens before that, error handling code calls hdpvr_delete(),
which contains iteration over the lists (via hdpvr_free_buffers()).
The patch moves the lists initialization to the beginning and by the way fixes
goto label in error handling of registering videodev.
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>
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Jianguo Wu <wujianguo@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
092bc21ef0
commit
96ca972634
1 changed files with 6 additions and 5 deletions
|
@ -309,6 +309,11 @@ static int hdpvr_probe(struct usb_interface *interface,
|
||||||
|
|
||||||
dev->workqueue = 0;
|
dev->workqueue = 0;
|
||||||
|
|
||||||
|
/* init video transfer queues first of all */
|
||||||
|
/* to prevent oops in hdpvr_delete() on error paths */
|
||||||
|
INIT_LIST_HEAD(&dev->free_buff_list);
|
||||||
|
INIT_LIST_HEAD(&dev->rec_buff_list);
|
||||||
|
|
||||||
/* 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)) {
|
||||||
err("v4l2_device_register failed");
|
err("v4l2_device_register failed");
|
||||||
|
@ -331,10 +336,6 @@ static int hdpvr_probe(struct usb_interface *interface,
|
||||||
if (!dev->workqueue)
|
if (!dev->workqueue)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* init video transfer queues */
|
|
||||||
INIT_LIST_HEAD(&dev->free_buff_list);
|
|
||||||
INIT_LIST_HEAD(&dev->rec_buff_list);
|
|
||||||
|
|
||||||
dev->options = hdpvr_default_options;
|
dev->options = hdpvr_default_options;
|
||||||
|
|
||||||
if (default_video_input < HDPVR_VIDEO_INPUTS)
|
if (default_video_input < HDPVR_VIDEO_INPUTS)
|
||||||
|
@ -409,7 +410,7 @@ static int hdpvr_probe(struct usb_interface *interface,
|
||||||
video_nr[atomic_inc_return(&dev_nr)]);
|
video_nr[atomic_inc_return(&dev_nr)]);
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
|
v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
|
||||||
goto error;
|
goto reg_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* let the user know what node this device is now attached to */
|
/* let the user know what node this device is now attached to */
|
||||||
|
|
Loading…
Reference in a new issue