mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ashay Jaiswal <ashayj@codeaurora.org>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	Anirudh Ghayal <aghayal@codeaurora.org>,
	Ashay Jaiswal <ashayj@codeaurora.org>
Subject: [PATCH] regulator: core: fix race condition in regulator_put()
Date: Wed,  7 Jan 2015 19:21:23 +0530	[thread overview]
Message-ID: <1420638683-20216-1-git-send-email-ashayj@codeaurora.org> (raw)

The regulator framework maintains a list of consumer regulators
for a regulator device and protects it from concurrent access
using the regulator device's mutex lock.

In the case of regulator_put() the consumer is removed without
holding the regulator device's mutex, resulting in a race condition
between any regulator operation which traverses the consumer list
and regulator_put() which releases the consumer regulator.
Fix this race condition by holding the regulator device's mutex while
removing and releasing the consumer regulator.

Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
---
 drivers/regulator/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c2554d8..3845397 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1498,6 +1498,7 @@ static void _regulator_put(struct regulator *regulator)

 	rdev = regulator->rdev;

+	mutex_lock(&rdev->mutex);
 	debugfs_remove_recursive(regulator->debugfs);

 	/* remove any sysfs entries */
@@ -1511,6 +1512,7 @@ static void _regulator_put(struct regulator *regulator)
 	rdev->exclusive = 0;

 	module_put(rdev->owner);
+	mutex_unlock(&rdev->mutex);
 }

 /**
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

             reply	other threads:[~2015-01-07 13:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-07 13:51 Ashay Jaiswal [this message]
2015-01-07 17:06 ` Mark Brown
2015-01-08 12:58   ` ashayj

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=1420638683-20216-1-git-send-email-ashayj@codeaurora.org \
    --to=ashayj@codeaurora.org \
    --cc=aghayal@codeaurora.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.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

Powered by JetHome