[PATCH] scsi: bnx2fc: Unmap SG list when BD list setup fails
From: Haoxiang Li
Date: Mon May 25 2026 - 03:18:43 EST
bnx2fc_map_sg() maps the SCSI SG list. If bd_count is larger
than BNX2FC_FW_MAX_BDS_PER_CMD, SG list should be unmapped.
Call bnx2fc_unmap_sg_list() to unmap the SG list from this
error path.
Fixes: 3c97b569505f ("scsi: bnx2fc: Limit the IO size according to the FW capability")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Haoxiang Li <lihaoxiang@xxxxxxxxxxxxxxxx>
---
drivers/scsi/bnx2fc/bnx2fc_io.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 33057908f147..5429f127c5b8 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1718,6 +1718,7 @@ static int bnx2fc_build_bd_list_from_sg(struct bnx2fc_cmd *io_req)
if (bd_count > BNX2FC_FW_MAX_BDS_PER_CMD) {
pr_err("bd_count = %d exceeded FW supported max BD(255), task_id = 0x%x\n",
bd_count, io_req->xid);
+ bnx2fc_unmap_sg_list(io_req);
return -ENOMEM;
}
--
2.25.1