From: Hans de Goede <hdegoede@redhat.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH] v4l2-ioctl: Don't assume file->private_data always points to a v4l2_fh
Date: Sat, 07 Jul 2012 21:21:00 +0200 [thread overview]
Message-ID: <4FF88C1C.5010402@redhat.com> (raw)
In-Reply-To: <201207072111.11951.hverkuil@xs4all.nl>
Hi,
On 07/07/2012 09:11 PM, Hans Verkuil wrote:
> On Sat July 7 2012 20:46:21 Hans de Goede wrote:
>> Commit efbceecd4522a41b8442c6b4f68b4508d57d1ccf, adds a number of helper
>> functions for ctrl related ioctls to v4l2-ioctl.c, these helpers assume that
>> if file->private_data != NULL, it points to a v4l2_fh, which is only the case
>> for drivers which actually use v4l2_fh.
>>
>> This breaks for example bttv which use the "filedata" pointer for its own uses,
>> and now all the ctrl ioctls try to use whatever its filedata points to as
>> v4l2_fh and think it has a ctrl_handler, leading to:
>>
>> [ 142.499214] BUG: unable to handle kernel NULL pointer dereference at 0000000000000021
>> [ 142.499270] IP: [<ffffffffa01cb959>] v4l2_queryctrl+0x29/0x230 [videodev]
>> [ 142.514649] [<ffffffffa01c7a77>] v4l_queryctrl+0x47/0x90 [videodev]
>> [ 142.517417] [<ffffffffa01c58b1>] __video_do_ioctl+0x2c1/0x420 [videodev]
>> [ 142.520116] [<ffffffffa01c7ee6>] video_usercopy+0x1a6/0x470 [videodev]
>> ...
>>
>> This patch adds the missing test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) tests
>> to the ctrl ioctl helpers v4l2_fh paths, fixing the issues with for example
>> the bttv driver.
>
> Urgh, I didn't test with a 'old' driver. Thanks for catching this. But I would
> prefer a simpler patch (although effectively the same) like this:
>
> diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
> index 70e0efb..bbcb4f6 100644
> --- a/drivers/media/video/v4l2-ioctl.c
> +++ b/drivers/media/video/v4l2-ioctl.c
> @@ -1486,7 +1486,7 @@ static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops,
> {
> struct video_device *vfd = video_devdata(file);
> struct v4l2_queryctrl *p = arg;
> - struct v4l2_fh *vfh = fh;
> + struct v4l2_fh *vfh = test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags) ? fh : NULL;
>
> if (vfh && vfh->ctrl_handler)
> return v4l2_queryctrl(vfh->ctrl_handler, p);
<snip>
I agree that that is better, so I've added that version to my tree now, for which I
expect / hope to send a pullreq later tonight.
Regards,
Hans
prev parent reply other threads:[~2012-07-07 19:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-07 18:46 [PATCH] v4l2-ioctl: Don't assume file->private_data always points to a v4l2_fh Hans de Goede
2012-07-07 19:11 ` Hans Verkuil
2012-07-07 19:21 ` Hans de Goede [this message]
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=4FF88C1C.5010402@redhat.com \
--to=hdegoede@redhat.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.