[PATCH] si470x: prevent resubmission
From: Oliver Neukum
Date: Mon Nov 18 2019 - 08:41:51 EST
Starting IO to a device is not necessarily a NOP in every error
case. So we need to terminate all IO in every case of probe
failure and disconnect with absolute certainty.
Signed-off-by: Oliver Neukum <oneukum@xxxxxxxx>
---
drivers/media/radio/si470x/radio-si470x-usb.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index fedff68d8c49..8663828d93a5 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -542,6 +542,8 @@ static int si470x_start_usb(struct si470x_device *radio)
radio->int_in_running = 0;
}
radio->status_rssi_auto_update = radio->int_in_running;
+ if (retval < 0)
+ return retval;
/* start radio */
retval = si470x_start(radio);
@@ -734,7 +736,8 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
/* start radio */
retval = si470x_start_usb(radio);
if (retval < 0)
- goto err_buf;
+ /* the urb may be running even after an error */
+ goto err_all;
/* set initial frequency */
si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
@@ -749,7 +752,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
return 0;
err_all:
- usb_kill_urb(radio->int_in_urb);
+ usb_poison_urb(radio->int_in_urb);
err_buf:
kfree(radio->buffer);
err_ctrl:
@@ -824,7 +827,7 @@ static void si470x_usb_driver_disconnect(struct usb_interface *intf)
mutex_lock(&radio->lock);
v4l2_device_disconnect(&radio->v4l2_dev);
video_unregister_device(&radio->videodev);
- usb_kill_urb(radio->int_in_urb);
+ usb_poison_urb(radio->int_in_urb);
usb_set_intfdata(intf, NULL);
mutex_unlock(&radio->lock);
v4l2_device_put(&radio->v4l2_dev);
--
2.16.4