From: Sun Ke <sunke32@huawei.com>
To: Markus Elfring <Markus.Elfring@web.de>,
Josef Bacik <josef@toxicpanda.com>, Jens Axboe <axboe@kernel.dk>,
<linux-block@vger.kernel.org>, <nbd@other.debian.org>
Cc: <linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH v2] nbd: Fix NULL pointer in flush_workqueue
Date: Tue, 2 Feb 2021 09:36:54 +0800 [thread overview]
Message-ID: <68668f92-b605-3abf-9e9a-cddf6444f478@huawei.com> (raw)
In-Reply-To: <ebe7beb2-336d-35d4-48af-8f8cad7b868b@web.de>
hi,Markus
在 2021/2/2 3:05, Markus Elfring 写道:
> …
>> +++ b/drivers/block/nbd.c
>> @@ -2011,12 +2011,14 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
>> index);
>> return -EINVAL;
>> }
>> + mutex_lock(&nbd->config_lock);
>> if (!refcount_inc_not_zero(&nbd->refs)) {
>> - mutex_unlock(&nbd_index_mutex);
>> - printk(KERN_ERR "nbd: device at index %d is going down\n",
>> - index);
>> - return -EINVAL;
>> + goto unlock;
>> }
>> + if (!nbd->recv_workq) {
>> + goto unlock;
>> + }
> How do you think about to use the following patch variant
> (so that unwanted curly brackets would be avoided for proposed single statements
> in two if branches)?
>
> + mutex_lock(&nbd->config_lock);
> - if (!refcount_inc_not_zero(&nbd->refs)) {
> + if (!refcount_inc_not_zero(&nbd->refs) || !nbd->recv_workq) {
> + mutex_unlock(&nbd->config_lock);
> mutex_unlock(&nbd_index_mutex);
> printk(KERN_ERR "nbd: device at index %d is going down\n",tter
> index);
> return -EINVAL;
> }
It looks better, thanks for your suggestion.
>
> By the way:
> Would you like to replace the following two statements by the statement
> “goto put_nbd;” in another update step for this function implementation?
>
> nbd_put(nbd);
> return 0;
Sure, I will do it.
>
> Regards,
> Markus
Thanks,
Sun Ke
> .
prev parent reply other threads:[~2021-02-02 1:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 8:19 Sun Ke
[not found] ` <ebe7beb2-336d-35d4-48af-8f8cad7b868b@web.de>
2021-02-02 1:36 ` Sun Ke [this message]
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=68668f92-b605-3abf-9e9a-cddf6444f478@huawei.com \
--to=sunke32@huawei.com \
--cc=Markus.Elfring@web.de \
--cc=axboe@kernel.dk \
--cc=josef@toxicpanda.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nbd@other.debian.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
all inboxes | Powered by JetHome®