From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Liu Ying <Ying.Liu@freescale.com>
Cc: linux-media@vger.kernel.org, m.chehab@samsung.com,
a.hajda@samsung.com, sakari.ailus@iki.fi, s.nawrocki@samsung.com,
hans.verkuil@cisco.com
Subject: Re: [PATCH] [media] v4l2-device: fix potential NULL pointer dereference for subdev unregister path
Date: Wed, 30 Apr 2014 18:27:07 +0200 [thread overview]
Message-ID: <1820972.unmABxgn1R@avalon> (raw)
In-Reply-To: <1398831921-5652-1-git-send-email-Ying.Liu@freescale.com>
Hi Liu,
Thank you for the patch.
On Wednesday 30 April 2014 12:25:21 Liu Ying wrote:
> The pointer 'sd->v4l2_dev' is likely to be NULL and dereferenced in the
> subdev unregister path. The issue should happen if CONFIG_MEDIA_CONTROLLER
> is defined.
>
> This patch fixes the issue by setting the pointer to be NULL after it will
> not be derefereneced any more in the path.
I'm not sure to understand the problem. Where do you see sd->v4l2_dev being
(potentially) dereferenced after being set to NULL ?
> Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
> Cc: Andrzej Hajda <a.hajda@samsung.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Cc: linux-media@vger.kernel.org
> Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
> ---
> drivers/media/v4l2-core/v4l2-device.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-device.c
> b/drivers/media/v4l2-core/v4l2-device.c index 02d1b63..d98d96f 100644
> --- a/drivers/media/v4l2-core/v4l2-device.c
> +++ b/drivers/media/v4l2-core/v4l2-device.c
> @@ -271,7 +271,6 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev
> *sd)
>
> if (sd->internal_ops && sd->internal_ops->unregistered)
> sd->internal_ops->unregistered(sd);
> - sd->v4l2_dev = NULL;
>
> #if defined(CONFIG_MEDIA_CONTROLLER)
> if (v4l2_dev->mdev) {
> @@ -279,6 +278,7 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev
> *sd) media_device_unregister_entity(&sd->entity);
> }
> #endif
> + v4l2_dev = NULL;
> video_unregister_device(sd->devnode);
> module_put(sd->owner);
> }
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2014-04-30 16:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 4:25 [PATCH] [media] v4l2-device: fix potential NULL pointer dereference for subdev unregister path Liu Ying
2014-04-30 16:27 ` Laurent Pinchart [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=1820972.unmABxgn1R@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=Ying.Liu@freescale.com \
--cc=a.hajda@samsung.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=s.nawrocki@samsung.com \
--cc=sakari.ailus@iki.fi \
/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