When probe() fails after calling v4l2_ctrl_handler_init(), the goto
err_dev error path skips v4l2_ctrl_handler_free(), leaking the memory
allocated for the control handler. Now that err_dev is no longer
referenced, remove the label as well.
Switching from goto err_dev to goto err_ctrl ensures that
v4l2_ctrl_handler_free() is called via the err_ctrl label, which
falls through to v4l2_device_unregister().
Fixes: 4967d53dbbce ("[media] si470x: Clean up, introduce the control framework")
Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
---
drivers/media/radio/si470x/radio-si470x-usb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 869b1e7e34b9..6272c2418408 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -655,7 +655,7 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
if (radio->hdl.error) {
retval = radio->hdl.error;
dev_err(&intf->dev, "couldn't register control\n");
- goto err_dev;
+ goto err_ctrl;
}
radio->videodev = si470x_viddev_template;
radio->videodev.ctrl_handler = &radio->hdl;
@@ -745,7 +745,6 @@ static int si470x_usb_driver_probe(struct usb_interface *intf,
kfree(radio->buffer);
err_ctrl:
v4l2_ctrl_handler_free(&radio->hdl);
-err_dev:
v4l2_device_unregister(&radio->v4l2_dev);
err_urb:
usb_free_urb(radio->int_in_urb);
--
2.25.1