Linux block layer
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: Cen Zhang <zzzccc427@gmail.com>, Jens Axboe <axboe@kernel.dk>,
	Keith Busch <kbusch@kernel.org>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	Damien Le Moal <dlemoal@kernel.org>,
	Genjian Zhang <zhanggenjian@kylinos.cn>,
	Hans Holmberg <hans.holmberg@wdc.com>,
	Kees Cook <kees@kernel.org>, Matthew Wilcox <willy@infradead.org>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Kyungchan Koh <kkc6196@fb.com>, Shaohua Li <shli@fb.com>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	baijiaju1990@gmail.com
Subject: Re: [PATCH] null_blk: cancel bw_timer on add-device error unwind
Date: Wed, 24 Jun 2026 19:51:10 +0530	[thread overview]
Message-ID: <f7919c52-1217-4a64-9e89-d03b70f49d65@linux.ibm.com> (raw)
In-Reply-To: <20260624071825.357098-1-zzzccc427@gmail.com>

On 6/24/26 12:48 PM, Cen Zhang wrote:
> null_blk starts the bandwidth hrtimer before the later add_disk/device_add
> failure points. If setup fails after the timer is queued, the shared error
> unwind frees struct nullb without draining bw_timer, so the callback can
> run on freed owner state.
> 
> The buggy scenario involves two paths, with each column showing the order
> within that path:
> 
> null_add_dev() error unwind:        nullb_bwtimer_fn() callback path:
> 1. Start bw_timer for a throttled   1. The hrtimer expires after the free.
>     device.                          2. nullb_bwtimer_fn() recovers the
> 2. Hit a later add_disk/device_add     embedded owner.
>     failure.                         3. The callback reads nullb->dev and
> 3. Free struct nullb.                  nullb->q.
> 4. Release the remaining queue and   4. The stale owner storage is used
>     disk resources.                     after free.
> 
> Cancel bw_timer in the shared error unwind before put_disk() and the
> remaining frees. The normal delete path already uses the same
> hrtimer_cancel() drain.

Looks good to me.
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>

      reply	other threads:[~2026-06-24 14:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24  7:18 [PATCH] null_blk: cancel bw_timer on add-device error unwind Cen Zhang
2026-06-24 14:21 ` Nilay Shroff [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=f7919c52-1217-4a64-9e89-d03b70f49d65@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=baijiaju1990@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dlemoal@kernel.org \
    --cc=hans.holmberg@wdc.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=kees@kernel.org \
    --cc=kkc6196@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shli@fb.com \
    --cc=willy@infradead.org \
    --cc=zhanggenjian@kylinos.cn \
    --cc=zzzccc427@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