[PATCH] scsi: Fix oversized data length in scsi_inquiry()
Alexey Charkov
alchark at flipper.net
Tue Mar 17 13:38:29 CET 2026
On Mon, Mar 16, 2026 at 8:42 PM Alexey Charkov <alchark at flipper.net> wrote:
>
> scsi_detect_dev() sets the inquiry data length to 512, but
> scsi_setup_inquiry() only sets the command up with a 255 byte length.
>
> This causes some SCSI devices such as the Foresee FEUDNN064G-C2G07 UFS
> chip to fail to respond to the inquiry command, preventing its detection.
>
> Set the data length to the size of the scsi_inquiry_resp structure, which
> is the maximum amount of data that scsi_setup_inquiry() will request.
>
> Fixes: 570712f4bcc4 ("scsi: Extract device detection algorithm")
> Signed-off-by: Alexey Charkov <alchark at flipper.net>
> ---
> drivers/scsi/scsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 8fe6b38a8c74..6a3a91b1d32b 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -513,7 +513,7 @@ static int scsi_detect_dev(struct udevice *dev, int target, int lun,
> pccb->target = target;
> pccb->lun = lun;
> pccb->pdata = tempbuff;
> - pccb->datalen = 512;
> + pccb->datalen = sizeof(struct scsi_inquiry_resp);
> pccb->dma_dir = DMA_FROM_DEVICE;
> scsi_setup_inquiry(pccb);
> if (scsi_exec(dev, pccb)) {
>
> ---
I noticed that Tom applied a patch by Macpaul Lin [1] which does
pretty much the same thing, which had already been reviewed and which
I haven't noticed before submitting mine (it landed in next nearly
simultaneously with me sending this out).
FWIW, I can confirm that Macpaul Lin's patch also fixes the issue I
had with my Foresee FEUDNN064G-C2G07 UFS chip, so my patch here can be
dropped.
Thanks a lot,
Alexey
[1] https://source.denx.de/u-boot/u-boot/-/commit/041364141b7daef8318a4b8495cac8570002773f
More information about the U-Boot
mailing list