From: Tyrel Datwyler <turtle.in.the.kernel@gmail.com>
To: "Ouyangzhaowei (Charles)" <ouyangzhaowei@huawei.com>,
jejb@linux.vnet.ibm.com, martin.petersen@oracle.com,
linux-kernel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org, Suoben <suoben@huawei.com>,
"Wulizhen (Pss)" <pss.wulizhen@huawei.com>
Subject: Re: [PATCH] scsi: shost->async_scan should be protected by mutex_lock
Date: Sun, 10 Sep 2017 18:44:26 -0700 [thread overview]
Message-ID: <8e8d0a1b-f053-6eab-a85a-ec83201b50be@gmail.com> (raw)
In-Reply-To: <f99d1494-af46-4f0f-5a24-bb88a860d0fe@huawei.com>
On 09/07/2017 11:54 PM, Ouyangzhaowei (Charles) wrote:
> shost->async_scan should be protected by mutex_lock, otherwise the check
> of "called twice" won't work.
>
> Signed-off-by: Ouyang Zhaowei <ouyangzhaowei@huawei.com>
> ---
> drivers/scsi/scsi_scan.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index fd88dab..1d1df51 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -1722,6 +1722,7 @@ static struct async_scan_data
> *scsi_prep_async_scan(struct Scsi_Host *shost)
> if (strncmp(scsi_scan_type, "sync", 4) == 0)
> return NULL;
>
> + mutex_lock(&shost->scan_mutex);
The mutex will not be unlocked in the event that either the host has called
scsi_prep_async_scan() twice, or a condition is meet the branches to the "err" label prior
to where the original mutex_lock() was located below.
-Tyrel
> if (shost->async_scan) {
> shost_printk(KERN_DEBUG, shost, "%s called twice\n",
> __func__);
> return NULL;
> @@ -1735,7 +1736,6 @@ static struct async_scan_data
> *scsi_prep_async_scan(struct Scsi_Host *shost)
> goto err;
> init_completion(&data->prev_finished);
>
> - mutex_lock(&shost->scan_mutex);
> spin_lock_irqsave(shost->host_lock, flags);
> shost->async_scan = 1;
> spin_unlock_irqrestore(shost->host_lock, flags);
>
next prev parent reply other threads:[~2017-09-11 1:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-08 6:54 Ouyangzhaowei (Charles)
2017-09-11 1:44 ` Tyrel Datwyler [this message]
2017-09-13 3:59 ` Ouyangzhaowei (Charles)
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=8e8d0a1b-f053-6eab-a85a-ec83201b50be@gmail.com \
--to=turtle.in.the.kernel@gmail.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ouyangzhaowei@huawei.com \
--cc=pss.wulizhen@huawei.com \
--cc=suoben@huawei.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 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®