From: Tomas Henzl <thenzl@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: take module reference during async scan
Date: Mon, 7 Sep 2020 23:12:27 +0200 [thread overview]
Message-ID: <d9b5672c-0265-8275-74df-ce1193730b6d@redhat.com> (raw)
In-Reply-To: <8dbf8936-0b56-b3c3-c62e-657bd2c931c8@acm.org>
On 9/7/20 6:57 PM, Bart Van Assche wrote:
> On 2020-09-07 08:47, Tomas Henzl wrote:
>> During an async scan the driver shost->hostt structures are used,
>> that may cause issues when the driver is removed at that time.
>> As protection take the module reference.
>>
>> Signed-off-by: Tomas Henzl <thenzl@redhat.com>
>> ---
>> drivers/scsi/scsi_scan.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>> index f2437a757..c9cc0862c 100644
>> --- a/drivers/scsi/scsi_scan.c
>> +++ b/drivers/scsi/scsi_scan.c
>> @@ -1825,6 +1825,8 @@ static void do_scan_async(void *_data, async_cookie_t c)
>>
>> do_scsi_scan_host(shost);
>> scsi_finish_async_scan(data);
>> +
>> + module_put(shost->hostt->module);
>> }
>>
>> /**
>> @@ -1848,6 +1850,12 @@ void scsi_scan_host(struct Scsi_Host *shost)
>> return;
>> }
>>
>> + /* protection against surprise driver removal
>> + * module_put is called from do_scan_async
>> + */
>> + if (!try_module_get(shost->hostt->module))
>> + return;
>> +
>> /* register with the async subsystem so wait_for_device_probe()
>> * will flush this work
>> */
>
> Shouldn't scsi_autopm_put_host(shost) be called if try_module_get() fails?
Thanks. Yes it should, I'll post a V2 if James agrees to this patch in
general in a parallel thread.
>
> Please also update the following comment in scsi_scan_host():
>
> /* scsi_autopm_put_host(shost) is called in scsi_finish_async_scan() */
It's late here so I'm tired and I miss something but how should I update
it ?
Thanks,
Tomas
>
> Thanks,
>
> Bart.
>
>
next prev parent reply other threads:[~2020-09-07 21:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-07 15:47 [PATCH] scsi: take module reference during async scan Tomas Henzl
2020-09-07 16:57 ` Bart Van Assche
2020-09-07 21:12 ` Tomas Henzl [this message]
2020-09-07 17:46 ` James Bottomley
2020-09-07 20:09 ` Tomas Henzl
2020-09-07 20:24 ` James Bottomley
2020-09-07 21:02 ` Tomas Henzl
2020-09-07 22:02 ` James Bottomley
2020-09-08 8:22 ` Tomas Henzl
2020-09-07 21:32 ` Douglas Gilbert
2020-09-07 22:56 ` James Bottomley
2020-09-08 14:04 ` John Garry
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=d9b5672c-0265-8275-74df-ce1193730b6d@redhat.com \
--to=thenzl@redhat.com \
--cc=bvanassche@acm.org \
--cc=linux-scsi@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;
as well as URLs for NNTP newsgroup(s).