linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 for v5.3] v4l2-subdev: fix regression in check_pad()
@ 2019-06-29 13:00 Hans Verkuil
  2019-07-02 12:15 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2019-06-29 13:00 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Niklas Söderlund, Janusz Krzysztofik, Sakari Ailus

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>
---
Changes in v2:

- Don't change the coding style, just fix the bug.
---
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 21fb90d66bfc..25c73c13cc7e 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCHv2 for v5.3] v4l2-subdev: fix regression in check_pad()
  2019-06-29 13:00 [PATCHv2 for v5.3] v4l2-subdev: fix regression in check_pad() Hans Verkuil
@ 2019-07-02 12:15 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2019-07-02 12:15 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Media Mailing List, Niklas Söderlund,
	Janusz Krzysztofik, Sakari Ailus, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]

 	Hi Hans,

On Sat, 29 Jun 2019, Hans Verkuil wrote:
> 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>

Thanks, this fixes the following boot regression on r8a7791/koelsch:

     -rcar-vin e6ef0000.video: Device registered as video27
     +rcar-vin e6ef0000.video: Unsupported media bus format for adv7612 13-004c
     +rcar-vin e6ef0000.video: Notifier registration failed
     +rcar-vin: probe of e6ef0000.video failed with error -22

Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

 						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
 							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-02 12:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-29 13:00 [PATCHv2 for v5.3] v4l2-subdev: fix regression in check_pad() Hans Verkuil
2019-07-02 12:15 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).