Re: [PATCH v2] scsi: ufs: core: Fix NULL pointer dereference in scsi_cmd_priv() calls
From: Peter Wang (王信友)
Date: Fri May 29 2026 - 05:14:38 EST
On Fri, 2026-05-29 at 10:07 +0900, Chanwoo Lee wrote:
> ufshcd_tag_to_cmd() may return NULL if no command is associated with
> the given tag. However, several callers dereference the returned cmd
> pointer via scsi_cmd_priv() without checking for NULL first, leading
> to a potential NULL pointer dereference.
>
> Fix this by adding NULL checks for cmd before calling scsi_cmd_priv()
> and moving the lrbp initialization after the NULL check.
>
> Signed-off-by: Chanwoo Lee <cw9316.lee@xxxxxxxxxxx>
> ---
Reviewed-by: Peter Wang <peter.wang@xxxxxxxxxxxx>