This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/media_tree.git tree:

Subject: [media] v4l: Validate fields in the core code for subdev EDID ioctls
Author:  Laurent Pinchart <[email protected]>
Date:    Wed Jan 29 10:07:13 2014 -0300

The subdev EDID ioctls receive a pad field that must reference an
existing pad and an EDID field that must point to a buffer. Validate
both fields in the core code instead of duplicating validation in all
drivers.

Signed-off-by: Laurent Pinchart <[email protected]>
Acked-by: Sakari Ailus <[email protected]>
Reviewed-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 drivers/media/i2c/ad9389b.c           |    2 --
 drivers/media/i2c/adv7511.c           |    2 --
 drivers/media/i2c/adv7604.c           |    4 ----
 drivers/media/i2c/adv7842.c           |    4 ----
 drivers/media/v4l2-core/v4l2-subdev.c |   24 ++++++++++++++++++++----
 5 files changed, 20 insertions(+), 16 deletions(-)

---

http://git.linuxtv.org/media_tree.git?a=commitdiff;h=f2e9084779d3ad3b51ee45a3a53fead3f16516ca

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index f00b3dd..fada175 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -682,8 +682,6 @@ static int ad9389b_get_edid(struct v4l2_subdev *sd, struct 
v4l2_edid *edid)
                return -EINVAL;
        if (edid->blocks == 0 || edid->blocks > 256)
                return -EINVAL;
-       if (!edid->edid)
-               return -EINVAL;
        if (!state->edid.segments) {
                v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
                return -ENODATA;
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index d77a1db..f98acf4 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -783,8 +783,6 @@ static int adv7511_get_edid(struct v4l2_subdev *sd, struct 
v4l2_edid *edid)
                return -EINVAL;
        if ((edid->blocks == 0) || (edid->blocks > 256))
                return -EINVAL;
-       if (!edid->edid)
-               return -EINVAL;
        if (!state->edid.segments) {
                v4l2_dbg(1, debug, sd, "EDID segment 0 not found\n");
                return -ENODATA;
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 98cc540..338baa4 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1673,8 +1673,6 @@ static int adv7604_get_edid(struct v4l2_subdev *sd, 
struct v4l2_edid *edid)
                return -EINVAL;
        if (edid->start_block == 1)
                edid->blocks = 1;
-       if (!edid->edid)
-               return -EINVAL;
 
        if (edid->blocks > state->edid.blocks)
                edid->blocks = state->edid.blocks;
@@ -1761,8 +1759,6 @@ static int adv7604_set_edid(struct v4l2_subdev *sd, 
struct v4l2_edid *edid)
                edid->blocks = 2;
                return -E2BIG;
        }
-       if (!edid->edid)
-               return -EINVAL;
 
        v4l2_dbg(2, debug, sd, "%s: write EDID pad %d, edid.present = 0x%x\n",
                        __func__, edid->pad, state->edid.present);
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index d85e125..0d55491 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2036,8 +2036,6 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, 
struct v4l2_edid *edid)
                return -EINVAL;
        if (edid->start_block == 1)
                edid->blocks = 1;
-       if (!edid->edid)
-               return -EINVAL;
 
        switch (edid->pad) {
        case ADV7842_EDID_PORT_A:
@@ -2072,8 +2070,6 @@ static int adv7842_set_edid(struct v4l2_subdev *sd, 
struct v4l2_edid *e)
                return -EINVAL;
        if (e->blocks > 2)
                return -E2BIG;
-       if (!e->edid)
-               return -EINVAL;
 
        /* todo, per edid */
        state->aspect_ratio = v4l2_calc_aspect_ratio(e->edid[0x15],
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index db126db..058c1a6 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -361,11 +361,27 @@ static long subdev_do_ioctl(struct file *file, unsigned 
int cmd, void *arg)
                        sd, pad, set_selection, subdev_fh, sel);
        }
 
-       case VIDIOC_G_EDID:
-               return v4l2_subdev_call(sd, pad, get_edid, arg);
+       case VIDIOC_G_EDID: {
+               struct v4l2_subdev_edid *edid = arg;
 
-       case VIDIOC_S_EDID:
-               return v4l2_subdev_call(sd, pad, set_edid, arg);
+               if (edid->pad >= sd->entity.num_pads)
+                       return -EINVAL;
+               if (edid->blocks && edid->edid == NULL)
+                       return -EINVAL;
+
+               return v4l2_subdev_call(sd, pad, get_edid, edid);
+       }
+
+       case VIDIOC_S_EDID: {
+               struct v4l2_subdev_edid *edid = arg;
+
+               if (edid->pad >= sd->entity.num_pads)
+                       return -EINVAL;
+               if (edid->blocks && edid->edid == NULL)
+                       return -EINVAL;
+
+               return v4l2_subdev_call(sd, pad, set_edid, edid);
+       }
 
        case VIDIOC_SUBDEV_DV_TIMINGS_CAP: {
                struct v4l2_dv_timings_cap *cap = arg;

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to