[PATCH v1] ufs: core: Fix possible NULL pointer dereference in ufshcd_add_command_trace()

Peter Wang (王信友) peter.wang at mediatek.com
Tue Feb 24 21:53:52 PST 2026


On Tue, 2026-02-24 at 08:48 -0800, Bart Van Assche wrote:
> Hi Peter,
> 
> That's not what I proposed. When ignoring the NULL test, this is what
> the current ufshcd_add_command_trace() implementation does:
> 
>         hwq_id = hba->uhq[READ_ONCE(req->mq_hctx)->queue_num].id;
> 
> That's more complicated than necessary. This should be sufficient
> (again ignoring the NULL test):
> 
>         hwq_id = READ_ONCE(req->mq_hctx)->queue_num;
> 
> Anyway, since the proposed change probably only results in a small
> performance improvement, let's proceed with the current patch.
> 
> Bart.

Hi Bart,

OK, I understand your point. However, there really shouldn’t
be a significant performance difference.
As for the patch with the fixes tag, I don’t think it’s 
necessarily an bug in that patch. It seems more like a corner
case that only occurs after errors happen consecutively.
Also, since Martin has already applied it, I won’t add the fixes
tag for now.

Thanks for the review.
Peter


More information about the Linux-mediatek mailing list