From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
hdegoede@redhat.com,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
Kate Hsuan <hpa@redhat.com>
Subject: [PATCH 1/1] media: v4l: subdev: Make link validation safer
Date: Thu, 9 Mar 2023 14:27:16 +0200 [thread overview]
Message-ID: <20230309122716.1624141-1-sakari.ailus@linux.intel.com> (raw)
Link validation currently accesses invalid pointers if the link passed to it
is not between two sub-devices. This is of course a driver bug.
Ignore the error but print a debug message, as this is how it used to work
previously.
Fixes: a6b995ed03ff ("media: subdev: use streams in v4l2_subdev_link_validate()")
Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reported-and-tested-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/media/v4l2-core/v4l2-subdev.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 1bebcda2bd20c..dd911180ec899 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1209,6 +1209,17 @@ int v4l2_subdev_link_validate(struct media_link *link)
struct v4l2_subdev_state *source_state, *sink_state;
int ret;
+ if (!is_media_entity_v4l2_subdev(link->sink->entity)) {
+ pr_warn_once("entity \"%s\" not a V4L2 sub-device, driver bug!\n",
+ link->sink->entity->name);
+ return 0;
+ }
+ if (!is_media_entity_v4l2_subdev(link->source->entity)) {
+ pr_warn_once("entity \"%s\" not a V4L2 sub-device, driver bug!\n",
+ link->source->entity->name);
+ return 0;
+ }
+
sink_sd = media_entity_to_v4l2_subdev(link->sink->entity);
source_sd = media_entity_to_v4l2_subdev(link->source->entity);
--
2.30.2
next reply other threads:[~2023-03-09 12:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 12:27 Sakari Ailus [this message]
2023-03-09 12:34 ` [PATCH 1/1] media: v4l: subdev: Make link validation safer Tomi Valkeinen
2023-03-09 12:35 ` Sakari Ailus
2023-03-09 12:34 ` Sakari Ailus
2023-03-09 12:43 ` Hans de Goede
2023-03-09 12:56 ` Sakari Ailus
2023-03-09 12:57 ` Tomi Valkeinen
2023-03-09 13:00 ` Sakari Ailus
2023-03-09 13:05 ` Hans de Goede
2023-03-12 13:01 ` Laurent Pinchart
-- strict thread matches above, loose matches on Subject: below --
2023-02-23 22:04 IPU3 cameras not working with latest kernel code ? Hans de Goede
2023-03-02 20:22 ` [PATCH 1/1] media: v4l: subdev: Make link validation safer Sakari Ailus
2023-03-03 8:41 ` Tomi Valkeinen
2023-03-03 11:30 ` Sakari Ailus
2023-03-03 11:36 ` Tomi Valkeinen
2023-03-03 15:06 ` Hans de Goede
2023-03-03 17:18 ` Sakari Ailus
2023-03-09 12:09 ` Hans de Goede
2023-03-09 12:28 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230309122716.1624141-1-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=hpa@redhat.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=tomi.valkeinen@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox