From: John Ogness <john.ogness@linutronix.de>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] regulator: core: grab supply info before unlocking
Date: Fri, 22 Apr 2016 16:33:51 +0200 [thread overview]
Message-ID: <87wpnp90hc.fsf@linutronix.de> (raw)
It is necessary to check if there is a supply while still holding
the regulator lock. Otherwise a theoretical race can occur that
someone else can add a supply and then we incorrectly try to
unlock that newly added regulator.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
patch against next-20160421
drivers/regulator/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 9348c78..629f92f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -161,10 +161,10 @@ static void regulator_unlock_supply(struct regulator_dev *rdev)
struct regulator *supply;
while (1) {
- mutex_unlock(&rdev->mutex);
supply = rdev->supply;
+ mutex_unlock(&rdev->mutex);
- if (!rdev->supply)
+ if (!supply)
return;
rdev = supply->rdev;
--
1.7.10.4
next reply other threads:[~2016-04-22 14:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-22 14:33 John Ogness [this message]
2016-04-22 15:07 ` [PATCH] regulator: core: grab supply info before unlocking Mark Brown
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=87wpnp90hc.fsf@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox