]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: sur40 - fix V4L error path cleanup
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 16 Jun 2026 05:12:30 +0000 (22:12 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 13 Aug 2026 00:51:54 +0000 (17:51 -0700)
In sur40_probe(), if video_register_device() fails, the error path jumps to
err_unreg_video. This incorrectly attempts to unregister a video device
that was never successfully registered, and fails to free the V4L2 control
handler (v4l2_ctrl_handler_free) that was initialized immediately prior.

Fix this by introducing an err_free_ctrl label to properly free the V4L2
control handler and bypass video_unregister_device() when video device
registration fails.

Reported-by: sashiko-bot@kernel.org
Cc: stable@vger.kernel.org
Assisted-by: Antigravity:gemini-3.5-flash
Link: https://patch.msgid.link/20260616051235.1549517-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/sur40.c

index 8639ec3ad703855897291f6de7c890d3cb0cd007..e9089b0c3e2f43df341d3d1d28d7e6087c1446b2 100644 (file)
@@ -787,7 +787,7 @@ static int sur40_probe(struct usb_interface *interface,
        if (error) {
                dev_err(&interface->dev,
                        "Unable to register video subdevice.");
-               goto err_unreg_video;
+               goto err_free_ctrl;
        }
 
        /* register the polled input device */
@@ -806,6 +806,8 @@ static int sur40_probe(struct usb_interface *interface,
 
 err_unreg_video:
        video_unregister_device(&sur40->vdev);
+err_free_ctrl:
+       v4l2_ctrl_handler_free(&sur40->hdl);
 err_unreg_v4l2:
        v4l2_device_unregister(&sur40->v4l2);
 err_free_buffer: