[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230227102411.3273877-1-dzm91@hust.edu.cn>
Date: Mon, 27 Feb 2023 18:24:08 +0800
From: Dongliang Mu <dzm91@...t.edu.cn>
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
Duoming Zhou <duoming@....edu.cn>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Dongliang Mu <dzm91@...t.edu.cn>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drivers: usb: smsusb: fix error handling code in smsusb_init_device
The previous commit 4b208f8b561f moves siano_media_device_register
before smscore_register_device, and adds corresponding error handling
code if smscore_register_device fails. However, it misses the following
error handling code of smsusb_init_device.
Fix this by moving error handling code at the end of smsusb_init_device
and adding a goto statement in the following error handling parts.
Fixes: 4b208f8b561f ("[media] siano: register media controller earlier")
Signed-off-by: Dongliang Mu <dzm91@...t.edu.cn>
---
drivers/media/usb/siano/smsusb.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 6f443c542c6d..07c3dd247e48 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -454,12 +454,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
rc = smscore_register_device(¶ms, &dev->coredev, 0, mdev);
if (rc < 0) {
pr_err("smscore_register_device(...) failed, rc %d\n", rc);
- smsusb_term_device(intf);
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
- media_device_unregister(mdev);
-#endif
- kfree(mdev);
- return rc;
+ goto err_unregister_device;
}
smscore_set_board_id(dev->coredev, board_id);
@@ -476,8 +471,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
rc = smsusb_start_streaming(dev);
if (rc < 0) {
pr_err("smsusb_start_streaming(...) failed\n");
- smsusb_term_device(intf);
- return rc;
+ goto err_unregister_device;
}
dev->state = SMSUSB_ACTIVE;
@@ -485,13 +479,20 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
rc = smscore_start_device(dev->coredev);
if (rc < 0) {
pr_err("smscore_start_device(...) failed\n");
- smsusb_term_device(intf);
- return rc;
+ goto err_unregister_device;
}
pr_debug("device 0x%p created\n", dev);
return rc;
+
+err_unregister_device:
+ smsusb_term_device(intf);
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+ media_device_unregister(mdev);
+#endif
+ kfree(mdev);
+ return rc;
}
static int smsusb_probe(struct usb_interface *intf,
--
2.39.1
Powered by blists - more mailing lists