From ff5e6c6df7d5b3c178b28f4987852b9cf1437616 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Mar 2021 10:29:38 +0100 Subject: [PATCH] 4.4-stable patches added patches: media-hdpvr-fix-an-error-handling-path-in-hdpvr_probe.patch --- ...n-error-handling-path-in-hdpvr_probe.patch | 120 ++++++++++++++++++ queue-4.4/series | 1 + 2 files changed, 121 insertions(+) create mode 100644 queue-4.4/media-hdpvr-fix-an-error-handling-path-in-hdpvr_probe.patch diff --git a/queue-4.4/media-hdpvr-fix-an-error-handling-path-in-hdpvr_probe.patch b/queue-4.4/media-hdpvr-fix-an-error-handling-path-in-hdpvr_probe.patch new file mode 100644 index 00000000000..13d4df4a258 --- /dev/null +++ b/queue-4.4/media-hdpvr-fix-an-error-handling-path-in-hdpvr_probe.patch @@ -0,0 +1,120 @@ +From c0f71bbb810237a38734607ca4599632f7f5d47f Mon Sep 17 00:00:00 2001 +From: Arvind Yadav +Date: Fri, 22 Sep 2017 09:07:06 -0400 +Subject: media: hdpvr: Fix an error handling path in hdpvr_probe() + +From: Arvind Yadav + +commit c0f71bbb810237a38734607ca4599632f7f5d47f 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 +Reported-by: Andrey Konovalov +Tested-by: Andrey Konovalov +Signed-off-by: Hans Verkuil +Signed-off-by: Mauro Carvalho Chehab +[krzk: backport to v4.4, still using single thread workqueue which + is drained/destroyed now in proper step so it cannot be NULL] +Signed-off-by: Krzysztof Kozlowski +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/media/usb/hdpvr/hdpvr-core.c | 33 +++++++++++++++++++-------------- + 1 file changed, 19 insertions(+), 14 deletions(-) + +--- a/drivers/media/usb/hdpvr/hdpvr-core.c ++++ b/drivers/media/usb/hdpvr/hdpvr-core.c +@@ -297,7 +297,7 @@ static int hdpvr_probe(struct usb_interf + /* register v4l2_device early so it can be used for printks */ + if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) { + dev_err(&interface->dev, "v4l2_device_register failed\n"); +- goto error; ++ goto error_free_dev; + } + + mutex_init(&dev->io_mutex); +@@ -306,7 +306,7 @@ static int hdpvr_probe(struct usb_interf + dev->usbc_buf = kmalloc(64, GFP_KERNEL); + if (!dev->usbc_buf) { + v4l2_err(&dev->v4l2_dev, "Out of memory\n"); +- goto error; ++ goto error_v4l2_unregister; + } + + init_waitqueue_head(&dev->wait_buffer); +@@ -314,7 +314,7 @@ static int hdpvr_probe(struct usb_interf + + dev->workqueue = create_singlethread_workqueue("hdpvr_buffer"); + if (!dev->workqueue) +- goto error; ++ goto err_free_usbc; + + dev->options = hdpvr_default_options; + +@@ -348,13 +348,13 @@ static int hdpvr_probe(struct usb_interf + } + if (!dev->bulk_in_endpointAddr) { + v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n"); +- goto error; ++ goto error_put_usb; + } + + /* init the device */ + if (hdpvr_device_init(dev)) { + v4l2_err(&dev->v4l2_dev, "device init failed\n"); +- goto error; ++ goto error_put_usb; + } + + mutex_lock(&dev->io_mutex); +@@ -362,7 +362,7 @@ static int hdpvr_probe(struct usb_interf + mutex_unlock(&dev->io_mutex); + v4l2_err(&dev->v4l2_dev, + "allocating transfer buffers failed\n"); +- goto error; ++ goto error_put_usb; + } + mutex_unlock(&dev->io_mutex); + +@@ -370,7 +370,7 @@ static int hdpvr_probe(struct usb_interf + retval = hdpvr_register_i2c_adapter(dev); + if (retval < 0) { + v4l2_err(&dev->v4l2_dev, "i2c adapter register failed\n"); +- goto error; ++ goto error_free_buffers; + } + + client = hdpvr_register_ir_rx_i2c(dev); +@@ -412,15 +412,20 @@ static int hdpvr_probe(struct usb_interf + reg_fail: + #if IS_ENABLED(CONFIG_I2C) + i2c_del_adapter(&dev->i2c_adapter); ++error_free_buffers: + #endif ++ hdpvr_free_buffers(dev); ++error_put_usb: ++ usb_put_dev(dev->udev); ++ /* Destroy single thread */ ++ destroy_workqueue(dev->workqueue); ++err_free_usbc: ++ kfree(dev->usbc_buf); ++error_v4l2_unregister: ++ v4l2_device_unregister(&dev->v4l2_dev); ++error_free_dev: ++ kfree(dev); + error: +- if (dev) { +- /* Destroy single thread */ +- if (dev->workqueue) +- destroy_workqueue(dev->workqueue); +- /* this frees allocated memory */ +- hdpvr_delete(dev); +- } + return retval; + } + diff --git a/queue-4.4/series b/queue-4.4/series index 104a57faa93..36a928a234f 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -66,3 +66,4 @@ alpha-move-exports-to-actual-definitions.patch alpha-get-rid-of-tail-zeroing-in-__copy_user.patch alpha-switch-__copy_user-and-__do_clean_user-to-normal-calling-conventions.patch powerpc-64s-fix-instruction-encoding-for-lis-in-ppc_function_entry.patch +media-hdpvr-fix-an-error-handling-path-in-hdpvr_probe.patch -- 2.47.3