From: Alexey Khoroshilov <khoroshilov@ispras.ru>
To: David Fries <David@Fries.net>, Evgeniy Polyakov <zbr@ioremap.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org
Subject: Re: [PATCH] w1: do not unlock unheld list_mutex in __w1_remove_master_device()
Date: Thu, 01 May 2014 00:45:18 +0400 [thread overview]
Message-ID: <536160DE.80508@ispras.ru> (raw)
In-Reply-To: <1398890278-15319-1-git-send-email-khoroshilov@ispras.ru>
As far as it is 3.15-rc1 regression introduced by 9fcbbac5ded48,
it makes sense to fix it in 3.15 cycle.
--
Alexey
On 01.05.2014 00:37, 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(). It is implemented by moving
> w1_process_callbacks() functionality to __w1_process_callbacks()
> and adding a wrapper with the old name.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/w1/w1.c | 8 +++++---
> drivers/w1/w1.h | 13 ++++++++++++-
> 2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index ff52618cafbe..e507c51512aa 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -1075,12 +1075,14 @@ static void w1_search_process(struct w1_master *dev, u8 search_type)
> }
>
> /**
> - * w1_process_callbacks() - execute each dev->async_list callback entry
> + * __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)
> +int __w1_process_callbacks(struct w1_master *dev)
> {
> int ret = 0;
> struct w1_async_cmd *async_cmd, *async_n;
> @@ -1122,7 +1124,7 @@ int w1_process(void *data)
> /* Note, w1_process_callback drops the lock while processing,
> * but locks it again before returning.
> */
> - if (!w1_process_callbacks(dev) && jremain) {
> + if (!__w1_process_callbacks(dev) && jremain) {
> /* a wake up is either to stop the thread, process
> * callbacks, or search, it isn't process callbacks, so
> * schedule a search.
> diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
> index 734dab7fc687..e357321a5e13 100644
> --- a/drivers/w1/w1.h
> +++ b/drivers/w1/w1.h
> @@ -341,9 +341,20 @@ extern int w1_max_slave_ttl;
> extern struct list_head w1_masters;
> extern struct mutex w1_mlock;
>
> -extern int w1_process_callbacks(struct w1_master *dev);
> +extern int __w1_process_callbacks(struct w1_master *dev);
> extern int w1_process(void *);
>
> +static inline int w1_process_callbacks(struct w1_master *dev)
> +{
> + int ret;
> +
> + mutex_lock(&dev->list_mutex);
> + ret = __w1_process_callbacks(dev);
> + mutex_unlock(&dev->list_mutex);
> + return ret;
> +}
> +
> +
> #endif /* __KERNEL__ */
>
> #endif /* __W1_H */
next prev parent reply other threads:[~2014-04-30 20:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 20:37 [PATCH] w1: do not unlock unheld list_mutex in __w1_remove_master_device() Alexey Khoroshilov
2014-04-30 20:45 ` Alexey Khoroshilov [this message]
2014-05-01 3:48 ` David Fries
2014-05-06 21:26 ` [PATCH v2] " Alexey Khoroshilov
2014-05-06 23:49 ` David Fries
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=536160DE.80508@ispras.ru \
--to=khoroshilov@ispras.ru \
--cc=David@Fries.net \
--cc=gregkh@linuxfoundation.org \
--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