Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Dongdong Hao <doubled@leap-io-kernel.com>,
	James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com
Cc: hare@kernel.org, hare@suse.de, yjzhang@leap-io-kernel.com,
	kezijie@leap-io-kernel.com, jzzhang@leap-io-kernel.com,
	baikefan@leap-io-kernel.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: leapraid: Fix init_cmd_priv error handling
Date: Wed, 4 Nov 2026 15:49:11 +0900	[thread overview]
Message-ID: <a161c75d-c8a2-4e44-8e33-30298622fc0c@kernel.org> (raw)
In-Reply-To: <20261104031823.198733-1-doubled@leap-io-kernel.com>

On 11/4/26 12:18, Dongdong Hao wrote:
> leapraid_init_cmd_priv() ignores the return value of
> leapraid_internal_init_cmd_priv() and always returns success. If
> dma_pool_alloc() fails, io_tracker->chain remains NULL, but the SCSI
> midlayer considers the command successfully initialized.
> 
> A subsequent I/O requiring more than LEAPRAID_SGL_INLINE_THRESHOLD
> DMA-mapped scatter-gather entries dereferences the NULL chain buffer
> while building the chained SGL, causing a kernel crash.
> 
> Return the result of leapraid_internal_init_cmd_priv() so that allocation
> failures propagate to the SCSI midlayer and abort initialization of the
> affected request.
> 
> Signed-off-by: Dongdong Hao <doubled@leap-io-kernel.com>
> ---
>  drivers/scsi/leapraid/leapraid_os.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/leapraid/leapraid_os.c b/drivers/scsi/leapraid/leapraid_os.c
> index da597eb99377..0f3219c4f438 100644
> --- a/drivers/scsi/leapraid/leapraid_os.c
> +++ b/drivers/scsi/leapraid/leapraid_os.c
> @@ -938,9 +938,8 @@ static int leapraid_init_cmd_priv(struct Scsi_Host *shost,
>  	struct leapraid_io_req_tracker *io_tracker;
>  
>  	io_tracker = scsi_cmd_priv(scmd);
> -	leapraid_internal_init_cmd_priv(adapter, io_tracker);
>  
> -	return 0;
> +	return leapraid_internal_init_cmd_priv(adapter, io_tracker);

	return leapraid_internal_init_cmd_priv(adapter, scsi_cmd_priv(scmd));

and you can remove the io_tracker local variable.

With that,

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

Note: when I sent out the SCSI ASC/ASCQ series rework, Sashiko had comments
about pre-existing issues in the leapraid driver. See:

https://sashiko.dev/#/message/20260831021810.235281F000E9%40smtp.kernel.org

You may want to check that.


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2026-11-04  6:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  3:18 [PATCH] scsi: leapraid: Fix init_cmd_priv error handling Dongdong Hao
2026-11-04  6:49 ` Damien Le Moal [this message]
2026-11-04  8:31   ` Hao Dongdong

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=a161c75d-c8a2-4e44-8e33-30298622fc0c@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=baikefan@leap-io-kernel.com \
    --cc=doubled@leap-io-kernel.com \
    --cc=hare@kernel.org \
    --cc=hare@suse.de \
    --cc=jzzhang@leap-io-kernel.com \
    --cc=kezijie@leap-io-kernel.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=yjzhang@leap-io-kernel.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