Re: [PATCH v2 6/6] block: skip queue if NULL on blk_cleanup_queue()
From: Luis Chamberlain
Date: Thu Jul 15 2021 - 15:29:53 EST
On Thu, Jul 15, 2021 at 08:11:57AM +0100, Christoph Hellwig wrote:
> On Wed, Jul 14, 2021 at 09:55:31PM -0700, Luis Chamberlain wrote:
> > Now that error handling for add_disk*() calls is added, we must
> > accept a common form for when errors are detected on the the
> > add_disk*() calls, and that is to call blk_cleanup_disk() on
> > error always. One of the corner cases possible is a driver bug
> > where the queue is already gone and we cannot blk_get_queue(),
> > and so may be NULL. When blk_cleanup_disk() is called in this
> > case blk_cleanup_queue() will crash with a null dereference.
> >
> > Make this an accepted condition and just skip it. This allows us
> > to also test for it safely with error injection.
>
> So you plan to call blk_cleanup_disk when add_disk fails?
Yes, they can open code things if they wish as well, but when possible yes.
> For all drivers using blk_alloc_disk/blk_mq_alloc_disk there should
> always be a queue. The others ones aren't ready to handle errors
> from add_disk yet in any way I think (and I plan to fix this up
> ASAP).
Have an example in mind?
Luis