Commit 62de7d99 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] usbtv: don't do DMA on stack

As reported by smatch:
	drivers/media/usb/usbtv/usbtv-video.c:716 usbtv_s_ctrl() error: doing dma on the stack (data)
	drivers/media/usb/usbtv/usbtv-video.c:758 usbtv_s_ctrl() error: doing dma on the stack (data)

We should not do it, as it won't work on Kernels 4.9 and upper.
So, alloc a buffer for it.

Fixes: c53a846c ("[media] usbtv: add video controls")
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent c53a846c
...@@ -704,10 +704,14 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -704,10 +704,14 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct usbtv *usbtv = container_of(ctrl->handler, struct usbtv, struct usbtv *usbtv = container_of(ctrl->handler, struct usbtv,
ctrl); ctrl);
u8 data[3]; u8 *data;
u16 index, size; u16 index, size;
int ret; int ret;
data = kmalloc(3, GFP_KERNEL);
if (!data)
return -ENOMEM;
/* /*
* Read in the current brightness/contrast registers. We need them * Read in the current brightness/contrast registers. We need them
* both, because the values are for some reason interleaved. * both, because the values are for some reason interleaved.
...@@ -717,6 +721,8 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -717,6 +721,8 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
usb_sndctrlpipe(usbtv->udev, 0), USBTV_CONTROL_REG, usb_sndctrlpipe(usbtv->udev, 0), USBTV_CONTROL_REG,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, USBTV_BASE + 0x0244, (void *)data, 3, 0); 0, USBTV_BASE + 0x0244, (void *)data, 3, 0);
if (ret < 0)
goto error;
} }
switch (ctrl->id) { switch (ctrl->id) {
...@@ -752,6 +758,7 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -752,6 +758,7 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
} }
break; break;
default: default:
kfree(data);
return -EINVAL; return -EINVAL;
} }
...@@ -759,12 +766,13 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -759,12 +766,13 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
USBTV_CONTROL_REG, USBTV_CONTROL_REG,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
0, index, (void *)data, size, 0); 0, index, (void *)data, size, 0);
if (ret < 0) {
error:
if (ret < 0)
dev_warn(usbtv->dev, "Failed to submit a control request.\n"); dev_warn(usbtv->dev, "Failed to submit a control request.\n");
return ret;
}
return 0; kfree(data);
return ret;
} }
static const struct v4l2_ctrl_ops usbtv_ctrl_ops = { static const struct v4l2_ctrl_ops usbtv_ctrl_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment