diff mbox series

[06/14] media: ov6650: Fix unverified pad IDs accepted by .get/set_selectioon()

Message ID 20190408214242.9603-7-jmkrzyszt@gmail.com (mailing list archive)
State New, archived
Headers show
Series media: ov6650: A collection of fixes | expand

Commit Message

Janusz Krzysztofik April 8, 2019, 9:42 p.m. UTC
Commit 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops")
converted former ov6650_g/s_crop() video operation callbacks to
ov6650_get/set_selection() pad operation callbacks.  However, the new
functions don't verify correctness of pad IDs passed in user arguments.
Fix it.

Even if pad ID arguments are not actually used in those functions,
assumed to be 0, always return -EINVAL if an operation on an invalid
(non-zero) pad is requested by a user.

Fixes: 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops")
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Cc: stable@vger.kernel.org
---
 drivers/media/i2c/ov6650.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index d72fcf56930a..5df81dec06ae 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -444,6 +444,9 @@  static int ov6650_get_selection(struct v4l2_subdev *sd,
 	struct i2c_client *client = v4l2_get_subdevdata(sd);
 	struct ov6650 *priv = to_ov6650(client);
 
+	if (sel->pad)
+		return -EINVAL;
+
 	if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE)
 		return -EINVAL;
 
@@ -471,6 +474,9 @@  static int ov6650_set_selection(struct v4l2_subdev *sd,
 	struct v4l2_rect rect = sel->r;
 	int ret;
 
+	if (sel->pad)
+		return -EINVAL;
+
 	if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE ||
 	    sel->target != V4L2_SEL_TGT_CROP)
 		return -EINVAL;