Re: [PATCH] block: Fix NULL pointer dereference in blk_mq_complete_request_remote

From: Srivatsa S. Bhat

Date: Wed Nov 18 2026 - 22:29:41 EST


On Wed, Nov 18, 2026 at 02:43:16PM -0700, Keith Busch wrote:
> On Wed, Nov 18, 2026 at 03:53:31PM -0500, Hamza Mahfooz wrote:
> > On Thu, Nov 19, 2026 at 12:58:44AM +0530, Srivatsa S. Bhat (Microsoft) wrote:
> > > Add NULL pointer validation in blk_mq_complete_request_remote() to
> > > prevent kernel crashes when block drivers pass freed request structures.
> > >
> >
> > This looks a lot like a driver bug, so it's probably best to hunt that
> > down instead of trying to work around it here.
>
> It would be better to go another level lower and fix the broken
> hardware. The "bug" is describing device behavior too far outside
> protocol to be usable.

Ah, I see. It was actually a firmware bug and it was root-caused and
fixed already, and that's why I'm not able to reproduce the crash
anymore (as it is not that straight-forward for me to revert back to
the buggy firmware environment).

Thank you Hamza and Keith for the feedback - I can now see where the
pushback is coming from. My bad, I should've been clearer about the
firmware fix -- without that clarification about the firmware bug being
fixed, I can totally see why this sounds like adding a workaround in
the kernel instead. I did add a note in the patch notes saying I'm not
able to repro the crash anymore, but I should've been clearer as to
*why* that's the case and not leave it as a mystery :-)

My motivation for this patch was to reduce the severity of the impact,
should a similar underlying hardware/firmware bug occur in the future
for any other platform. Instead of causing a kernel panic and bringing
down the entire system, I was hoping that the NULL check could help
isolate it down to just failed I/O operations (along with a warning to
help with investigation).

But the sashiko review also seems to be hinting that such a NULL check
is insufficient and won't be race-free, even if we wanted to go down
that route of isolating the fault than panicking the kernel. (I had
also noted down my own question and uncertainty about the rq->state
management in the patch notes).

So, my takeaway from this discussion is that this is probably best
left as is in the kernel, since it complicates blk-mq recovery (a
simple NULL check being insufficient), and instead rely on the
firmware/hardware working correctly for this scenario.

Thank you!

Regards,
Srivatsa