]> git.dujemihanovic.xyz Git - linux.git/commitdiff
media: v4l2-subdev: fix regression in check_pad()
authorHans Verkuil <hverkuil@xs4all.nl>
Sat, 29 Jun 2019 13:00:10 +0000 (09:00 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 11 Jul 2019 12:59:54 +0000 (08:59 -0400)
sd->entity.graph_obj.mdev can be NULL when this function is called, and
that breaks existing drivers (rcar-vin, but probably others as well).

Check if sd->entity.num_pads is non-zero instead since that doesn't depend
on mdev.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Fixes: a8fa55078a77 ("media: v4l2-subdev: Verify arguments in v4l2_subdev_call()")
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/v4l2-core/v4l2-subdev.c

index 21fb90d66bfc319b4e27ad073f3126fe496a98b8..25c73c13cc7ef830b72b70de39015bd8e48190d7 100644 (file)
@@ -124,7 +124,7 @@ static inline int check_which(__u32 which)
 static inline int check_pad(struct v4l2_subdev *sd, __u32 pad)
 {
 #if defined(CONFIG_MEDIA_CONTROLLER)
-       if (sd->entity.graph_obj.mdev) {
+       if (sd->entity.num_pads) {
                if (pad >= sd->entity.num_pads)
                        return -EINVAL;
                return 0;