From: David Fries <David@Fries.net>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Evgeniy Polyakov <zbr@ioremap.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
Subject: Re: [PATCH v2] w1: do not unlock unheld list_mutex in __w1_remove_master_device()
Date: Tue, 6 May 2014 18:49:30 -0500 [thread overview]
Message-ID: <20140506234930.GU21508@spacedout.fries.net> (raw)
In-Reply-To: <1399411564-16172-1-git-send-email-khoroshilov@ispras.ru>
Acked-by: David Fries <david@fries.net>
On Wed, May 07, 2014 at 01:26:04AM +0400, Alexey Khoroshilov wrote:
> w1_process_callbacks() expects to be called with dev->list_mutex held,
> but it is the fact only in w1_process(). __w1_remove_master_device()
> calls w1_process_callbacks() after it releases list_mutex.
>
> The patch fixes __w1_remove_master_device() to acquire list_mutex
> for w1_process_callbacks().
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/w1/w1.c | 2 ++
> drivers/w1/w1_int.c | 4 ++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index ff52618cafbe..5d7341520544 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -1078,6 +1078,8 @@ static void w1_search_process(struct w1_master *dev, u8 search_type)
> * w1_process_callbacks() - execute each dev->async_list callback entry
> * @dev: w1_master device
> *
> + * The w1 master list_mutex must be held.
> + *
> * Return: 1 if there were commands to executed 0 otherwise
> */
> int w1_process_callbacks(struct w1_master *dev)
> diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
> index 9b084db739c7..728039d2efe1 100644
> --- a/drivers/w1/w1_int.c
> +++ b/drivers/w1/w1_int.c
> @@ -219,9 +219,13 @@ void __w1_remove_master_device(struct w1_master *dev)
>
> if (msleep_interruptible(1000))
> flush_signals(current);
> + mutex_lock(&dev->list_mutex);
> w1_process_callbacks(dev);
> + mutex_unlock(&dev->list_mutex);
> }
> + mutex_lock(&dev->list_mutex);
> w1_process_callbacks(dev);
> + mutex_unlock(&dev->list_mutex);
>
> memset(&msg, 0, sizeof(msg));
> msg.id.mst.id = dev->id;
> --
> 1.8.3.2
--
David Fries <david@fries.net> PGP pub CB1EE8F0
http://fries.net/~david/
next prev parent reply other threads:[~2014-05-06 23:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 20:37 [PATCH] " Alexey Khoroshilov
2014-04-30 20:45 ` Alexey Khoroshilov
2014-05-01 3:48 ` David Fries
2014-05-06 21:26 ` [PATCH v2] " Alexey Khoroshilov
2014-05-06 23:49 ` David Fries [this message]
2014-05-06 23:51 ` zbr
2014-05-06 21:42 ` [PATCH] " Alexey Khoroshilov
2014-05-06 23:49 ` David Fries
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=20140506234930.GU21508@spacedout.fries.net \
--to=david@fries.net \
--cc=gregkh@linuxfoundation.org \
--cc=khoroshilov@ispras.ru \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zbr@ioremap.net \
/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
all inboxes | Powered by JetHome®