[PATCH] media: usbtv: Return zero on successful control transfers

From: raoxu

Date: Mon Nov 16 2026 - 04:00:20 EST


From: Xu Rao <raoxu@xxxxxxxxxxxxx>

usbtv_s_ctrl() returns the byte count from usb_control_msg() after a
successful control write. The supported controls transfer two or three
bytes, so the callback returns a positive value instead of the zero
expected by the V4L2 control core.

As a result, try_or_set_cluster() exits without committing the new
control value to its cached current value. VIDIOC_S_CTRL can therefore
program the hardware while a subsequent VIDIOC_G_CTRL still reports
the previous value.

The positive return also causes v4l2_ctrl_handler_setup() to stop
after the first control, leaving the remaining controls unapplied
when video capture starts.

The regression was introduced by commit 62de7d99dcfe ("[media] usbtv:
don't do DMA on stack"), which moved the USB transfer buffer from the
stack to dynamically allocated memory but inadvertently changed the
success return from zero to the transferred byte count.

Reproduced against the running V4L2 control framework using temporary
video nodes with copies of the usbtv control callback and simulated
successful USB transfers. The results were:

brightness (448 -> 449):
original: S_CTRL returned 3, G_CTRL returned 448
fixed: S_CTRL returned 0, G_CTRL returned 449

saturation (512 -> 513):
original: S_CTRL returned 2, G_CTRL returned 512
fixed: S_CTRL returned 0, G_CTRL returned 513

v4l2_ctrl_handler_setup():
original: 1 of 5 control callbacks executed
fixed: all 5 control callbacks executed

Simulated -EPIPE and -ETIMEDOUT errors continued to propagate without
updating the cached values. The test exercised the real V4L2 control
framework, but USB transfers were simulated; no physical USBTV007
device was available.

Return zero for nonnegative USB transfer results while preserving
negative errors and the existing buffer cleanup.

Fixes: 62de7d99dcfe ("[media] usbtv: don't do DMA on stack")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
---
drivers/media/usb/usbtv/usbtv-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 2a91af8d1e30..92c745d61367 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -865,7 +865,7 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
dev_warn(usbtv->dev, "Failed to submit a control request.\n");

kfree(data);
- return ret;
+ return ret < 0 ? ret : 0;
}

static const struct v4l2_ctrl_ops usbtv_ctrl_ops = {
--
2.50.1