All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
	Daniel Vetter <daniel.vetter@intel.com>,
	dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Inki Dae <inki.dae@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Patrice.chotard@st.com, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv6 01/10] media: add CEC notifier support
Date: Sat, 1 Apr 2017 10:39:00 +0100	[thread overview]
Message-ID: <20170401093900.GX7909@n2100.armlinux.org.uk> (raw)
In-Reply-To: <dabb03d5-1631-aab3-259e-7f02ad60f571@xs4all.nl>

On Sat, Apr 01, 2017 at 11:22:03AM +0200, Hans Verkuil wrote:
> On 31/03/17 22:46, Russell King - ARM Linux wrote:
> > On Fri, Mar 31, 2017 at 02:20:27PM +0200, Hans Verkuil wrote:
> >> +struct cec_notifier *cec_notifier_get(struct device *dev)
> >> +{
> >> +	struct cec_notifier *n;
> >> +
> >> +	mutex_lock(&cec_notifiers_lock);
> >> +	list_for_each_entry(n, &cec_notifiers, head) {
> >> +		if (n->dev == dev) {
> >> +			mutex_unlock(&cec_notifiers_lock);
> >> +			kref_get(&n->kref);
> > 
> > Isn't this racy?  What stops one thread trying to get the notifier
> > while another thread puts the notifier?
> > 
> 
> Both get and put take the global cec_notifiers_lock mutex.

No, that doesn't help:

Thread 0			Thread 1
mutex_lock()
list_for_each_entry()
if()
mutex_unlock()
				mutex_lock()
				kref_put()
					list_del()
					kfree()
				mutex_unlock()
kref_get()

So, it's possible that kref_get() can be called on kfree'd memory.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2017-04-01  9:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-31 12:20 [PATCHv6 00/10] video/exynos/sti/cec: add CEC notifier & use in drivers Hans Verkuil
2017-03-31 12:20 ` Hans Verkuil
2017-03-31 12:20 ` [PATCHv6 01/10] media: add CEC notifier support Hans Verkuil
2017-03-31 20:46   ` Russell King - ARM Linux
2017-04-01  9:22     ` Hans Verkuil
2017-04-01  9:22       ` Hans Verkuil
2017-04-01  9:39       ` Russell King - ARM Linux [this message]
2017-04-01  9:43         ` Hans Verkuil
2017-03-31 12:20 ` [PATCHv6 02/10] cec: integrate " Hans Verkuil
2017-03-31 12:20   ` Hans Verkuil
2017-03-31 12:20 ` [PATCHv6 03/10] exynos_hdmi: add " Hans Verkuil
2017-04-07 12:07   ` Andrzej Hajda
2017-03-31 12:20 ` [PATCHv6 04/10] ARM: dts: exynos: add HDMI controller phandle to exynos4.dtsi Hans Verkuil
2017-03-31 12:20   ` Hans Verkuil
     [not found] ` <20170331122036.55706-1-hverkuil-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org>
2017-03-31 12:20   ` [PATCHv6 05/10] s5p-cec.txt: document the HDMI controller phandle Hans Verkuil
2017-03-31 12:20     ` Hans Verkuil
2017-04-03 16:43     ` Rob Herring
2017-04-03 16:43       ` Rob Herring
2017-03-31 12:20 ` [PATCHv6 06/10] s5p-cec: add cec-notifier support, move out of staging Hans Verkuil
2017-03-31 12:20   ` Hans Verkuil
2017-03-31 12:20 ` [PATCHv6 07/10] sti: hdmi: add CEC notifier support Hans Verkuil
2017-03-31 12:20 ` [PATCHv6 08/10] stih-cec.txt: document new hdmi phandle Hans Verkuil
2017-03-31 12:20   ` Hans Verkuil
2017-03-31 12:20 ` [PATCHv6 09/10] stih-cec: add CEC notifier support Hans Verkuil
2017-03-31 12:20 ` [PATCHv6 10/10] ARM: dts: STiH410: update sti-cec for " Hans Verkuil
2017-03-31 12:20   ` Hans Verkuil
2017-03-31 14:39 ` [PATCHv6 00/10] video/exynos/sti/cec: add CEC notifier & use in drivers Russell King - ARM Linux
2017-03-31 16:35   ` Russell King - ARM Linux

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=20170401093900.GX7909@n2100.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Patrice.chotard@st.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=inki.dae@samsung.com \
    --cc=javier@osg.samsung.com \
    --cc=krzk@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.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.