All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: mchehab@kernel.org, mkrufky@linuxtv.org, klock.android@gmail.com,
	elfring@users.sourceforge.net, max@duempel.org,
	hans.verkuil@cisco.com, javier@osg.samsung.com,
	chehabrafael@gmail.com, sakari.ailus@linux.intel.com,
	laurent.pinchart+renesas@ideasonboard.com
Cc: Shuah Khan <shuahkh@osg.samsung.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] media: au0828 fix to protect enable/disable source set and clear
Date: Mon, 28 Nov 2016 19:15:13 -0700	[thread overview]
Message-ID: <6a4776ad1450ecf6ce73e5c005e0549fc29e7710.1480384155.git.shuahkh@osg.samsung.com> (raw)
In-Reply-To: <cover.1480384155.git.shuahkh@osg.samsung.com>
In-Reply-To: <cover.1480384155.git.shuahkh@osg.samsung.com>

Protect enable/disable source set and clear to avoid races with callers.
There is a possibility clear could occur while dvb-core and v4l2 try to
access these handlers.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 drivers/media/usb/au0828/au0828-core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index bf53553..a1f696a 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -153,9 +153,11 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
 	}
 
 	/* clear enable_source, disable_source */
+	mutex_lock(&mdev->graph_mutex);
 	dev->media_dev->source_priv = NULL;
 	dev->media_dev->enable_source = NULL;
 	dev->media_dev->disable_source = NULL;
+	mutex_unlock(&mdev->graph_mutex);
 
 	media_device_unregister(dev->media_dev);
 	media_device_cleanup(dev->media_dev);
@@ -549,9 +551,11 @@ static int au0828_media_device_register(struct au0828_dev *dev,
 		return ret;
 	}
 	/* set enable_source */
+	mutex_lock(&dev->media_dev->graph_mutex);
 	dev->media_dev->source_priv = (void *) dev;
 	dev->media_dev->enable_source = au0828_enable_source;
 	dev->media_dev->disable_source = au0828_disable_source;
+	mutex_unlock(&dev->media_dev->graph_mutex);
 #endif
 	return 0;
 }
-- 
2.7.4

  reply	other threads:[~2016-11-29  2:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29  2:15 [PATCH 0/2] media protect enable and disable source handler paths Shuah Khan
2016-11-29  2:15 ` Shuah Khan [this message]
2016-11-29  2:15 ` [PATCH 2/2] media: protect enable and disable source handler checks and calls Shuah Khan
2016-11-29  9:22   ` Sakari Ailus
2016-11-29 17:41     ` Shuah Khan
2016-12-01 13:51       ` Sakari Ailus
2016-12-01 16:51         ` Shuah Khan
2016-11-29  9:15 ` [PATCH 0/2] media protect enable and disable source handler paths Mauro Carvalho Chehab
2016-11-29 17:07   ` Shuah Khan
2016-11-29 17:17     ` Mauro Carvalho Chehab

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=6a4776ad1450ecf6ce73e5c005e0549fc29e7710.1480384155.git.shuahkh@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=chehabrafael@gmail.com \
    --cc=elfring@users.sourceforge.net \
    --cc=hans.verkuil@cisco.com \
    --cc=javier@osg.samsung.com \
    --cc=klock.android@gmail.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=max@duempel.org \
    --cc=mchehab@kernel.org \
    --cc=mkrufky@linuxtv.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 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.