public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Yu Kuai <yukuai3@huawei.com>,
	linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Bart Van Assche <bvanassche@acm.org>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	Chengming Zhou <zhouchengming@bytedance.com>,
	Damien Le Moal <dlemoal@kernel.org>,
	Hannes Reinecke <hare@suse.de>, Jens Axboe <axboe@kernel.dk>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Yi Zhang <yi.zhang@redhat.com>, Zhu Yanjun <yanjun.zhu@linux.dev>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Yang Erkun <yangerkun@huawei.com>, Yi Zhang <yi.zhang@huawei.com>,
	Yu Kuai <yukuai1@huaweicloud.com>
Subject: Re: [PATCH v2] null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues'
Date: Sun, 26 May 2024 14:57:07 +0200	[thread overview]
Message-ID: <369912bd-2ccf-4cb7-817a-a32ccbb3d83d@web.de> (raw)
In-Reply-To: <20240523153934.1937851-1-yukuai1@huaweicloud.com>

…
> Fix this problem by resuing the global mutex to protect
> nullb_device_power_store() and nullb_update_nr_hw_queues() from configfs.
>
> Fixes: 45919fbfe1c4 ("null_blk: Enable modifying 'submit_queues' after an instance has been configured")
> +++ b/drivers/block/null_blk/main.c
> @@ -413,13 +413,25 @@ static int nullb_update_nr_hw_queues(struct nullb_device *dev,
>  static int nullb_apply_submit_queues(struct nullb_device *dev,
>  				     unsigned int submit_queues)
>  {
> -	return nullb_update_nr_hw_queues(dev, submit_queues, dev->poll_queues);
> +	int ret;
> +
> +	mutex_lock(&lock);
> +	ret = nullb_update_nr_hw_queues(dev, submit_queues, dev->poll_queues);
> +	mutex_unlock(&lock);
> +
> +	return ret;
>  }
…

How do you think about to increase the application of scope-based resource management here?
https://elixir.bootlin.com/linux/v6.9.1/source/include/linux/cleanup.h#L124

Will development interests grow for the usage of a statement like “guard(mutex)(&lock);”?

Regards,
Markus

  parent reply	other threads:[~2024-05-26 12:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23 15:39 [PATCH v2] null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues' Yu Kuai
2024-05-23  7:47 ` Zhu Yanjun
2024-05-25 16:09 ` Jens Axboe
2024-05-26 12:57 ` Markus Elfring [this message]
2024-05-27  7:38   ` Johannes Thumshirn

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=369912bd-2ccf-4cb7-817a-a32ccbb3d83d@web.de \
    --to=markus.elfring@web.de \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=dlemoal@kernel.org \
    --cc=hare@suse.de \
    --cc=johannes.thumshirn@wdc.com \
    --cc=kch@nvidia.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yanjun.zhu@linux.dev \
    --cc=yi.zhang@huawei.com \
    --cc=yi.zhang@redhat.com \
    --cc=yukuai1@huaweicloud.com \
    --cc=yukuai3@huawei.com \
    --cc=zhouchengming@bytedance.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