public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Liu Ying <Ying.Liu@freescale.com>
To: <linux-media@vger.kernel.org>
Cc: <m.chehab@samsung.com>, <a.hajda@samsung.com>,
	<laurent.pinchart@ideasonboard.com>, <sakari.ailus@iki.fi>,
	<s.nawrocki@samsung.com>, <hans.verkuil@cisco.com>
Subject: [PATCH] [media] v4l2-device: fix potential NULL pointer dereference for subdev unregister path
Date: Wed, 30 Apr 2014 12:25:21 +0800	[thread overview]
Message-ID: <1398831921-5652-1-git-send-email-Ying.Liu@freescale.com> (raw)

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.

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);
 }
-- 
1.7.9.5


             reply	other threads:[~2014-04-30  4:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-30  4:25 Liu Ying [this message]
2014-04-30 16:27 ` [PATCH] [media] v4l2-device: fix potential NULL pointer dereference for subdev unregister path Laurent Pinchart

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=1398831921-5652-1-git-send-email-Ying.Liu@freescale.com \
    --to=ying.liu@freescale.com \
    --cc=a.hajda@samsung.com \
    --cc=hans.verkuil@cisco.com \
    --cc=laurent.pinchart@ideasonboard.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