From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Janusz Krzysztofik <jmkrzyszt@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/4] media: v4l2-subdev: WARN_ON invalid v4l2_subdev_call() arguments
Date: Tue, 14 May 2019 13:54:36 +0200 [thread overview]
Message-ID: <c9f6b614-2f60-9f54-cfbd-ec218e582f33@xs4all.nl> (raw)
In-Reply-To: <20190512201551.18724-3-jmkrzyszt@gmail.com>
On 5/12/19 10:15 PM, Janusz Krzysztofik wrote:
> Invalid arguments passed to v4l2_subdev_call generally mean bugs. Be
> noisy if that happens.
>
> Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> ---
> drivers/media/v4l2-core/v4l2-subdev.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 890916674d42..5f2264575cd7 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -122,8 +122,8 @@ static int subdev_close(struct file *file)
>
> static int check_which(__u32 which)
> {
> - if (which != V4L2_SUBDEV_FORMAT_TRY &&
> - which != V4L2_SUBDEV_FORMAT_ACTIVE)
> + if (WARN_ON(which != V4L2_SUBDEV_FORMAT_TRY &&
> + which != V4L2_SUBDEV_FORMAT_ACTIVE))
> return -EINVAL;
But this is now also called when the user calls an ioctl. And in that
case there should be no warning. It's perfectly legal for userspace to
specify a random value for which, and in that case it is just a regular
userspace bug. Same for the other checks below.
Regards,
Hans
>
> return 0;
> @@ -132,7 +132,7 @@ static int check_which(__u32 which)
> static int check_pad(struct v4l2_subdev *sd, __u32 pad)
> {
> #if defined(CONFIG_MEDIA_CONTROLLER)
> - if (sd->entity.num_pads && pad >= sd->entity.num_pads)
> + if (WARN_ON(sd->entity.num_pads && pad >= sd->entity.num_pads))
> return -EINVAL;
> #endif
> return 0;
> @@ -228,7 +228,7 @@ static int check_set_selection(struct v4l2_subdev *sd,
>
> static int check_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid)
> {
> - if (edid->blocks && edid->edid == NULL)
> + if (WARN_ON(edid->blocks && edid->edid == NULL))
> return -EINVAL;
>
> return check_pad(sd, edid->pad);
>
next prev parent reply other threads:[~2019-05-14 11:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-12 20:15 [PATCH v5 0/4] media: v4l2-subdev: Verify arguments in v4l2_subdev_call() Janusz Krzysztofik
2019-05-12 20:15 ` [PATCH v5 1/4] " Janusz Krzysztofik
2019-05-14 11:56 ` Hans Verkuil
2019-05-12 20:15 ` [PATCH v5 2/4] media: v4l2-subdev: WARN_ON invalid v4l2_subdev_call() arguments Janusz Krzysztofik
2019-05-14 11:54 ` Hans Verkuil [this message]
2019-05-12 20:15 ` [PATCH v5 3/4] media: v4l2-subdev: Verify v4l2_subdev_call() pointer arguments Janusz Krzysztofik
2019-05-12 20:15 ` [PATCH v5 4/4] media: v4l2-subdev: Verify v4l2_subdev_call() pad config argument Janusz Krzysztofik
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=c9f6b614-2f60-9f54-cfbd-ec218e582f33@xs4all.nl \
--to=hverkuil-cisco@xs4all.nl \
--cc=jmkrzyszt@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.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;
as well as URLs for NNTP newsgroup(s).