From: "Ouyangzhaowei (Charles)" <ouyangzhaowei@huawei.com>
To: Tyrel Datwyler <turtle.in.the.kernel@gmail.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: [RESEND PATCH] scsi: shost->async_scan should be protected by mutex_lock
Date: Fri, 13 Oct 2017 14:55:18 +0800 [thread overview]
Message-ID: <aae2bdef-2c21-d97d-43f5-5aff2934e8a9@huawei.com> (raw)
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 | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index fd88dab..20d539b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1722,9 +1722,10 @@ 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);
if (shost->async_scan) {
shost_printk(KERN_DEBUG, shost, "%s called twice\n",
__func__);
- return NULL;
+ goto unlock;
}
data = kmalloc(sizeof(*data), GFP_KERNEL);
@@ -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);
@@ -1751,6 +1751,8 @@ static struct async_scan_data
*scsi_prep_async_scan(struct Scsi_Host *shost)
err:
kfree(data);
+ unlock:
+ mutex_unlock(&shost->scan_mutex);
return NULL;
}
reply other threads:[~2017-10-13 6:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=aae2bdef-2c21-d97d-43f5-5aff2934e8a9@huawei.com \
--to=ouyangzhaowei@huawei.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=pss.wulizhen@huawei.com \
--cc=suoben@huawei.com \
--cc=turtle.in.the.kernel@gmail.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;
as well as URLs for NNTP newsgroup(s).