Skip to contentSkip to conversation

lpfc: Resolve checker warning for lpfc_new_io_buf()

PATCH Applied James Smart 2 participants 2 messages Aug 27, 2019 – Aug 29, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lpfc: Resolve checker warning for lpfc_new_io_buf()

Per Dan Carpenter:
The patch d79c9e9d4b3d: "scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware." from Aug 14, 2019, leads to the following static checker warning:

drivers/scsi/lpfc/lpfc_init.c:4107 lpfc_new_io_buf()
error: not allocating enough data 784 vs 768

There was no need to compare sizes nor to allocate size based on a define.

Change allocation to use actual structure length

---
 drivers/scsi/lpfc/lpfc_init.c | 11 +----------
 drivers/scsi/lpfc/lpfc_sli4.h |  3 ---
 2 files changed, 1 insertion(+), 13 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +1 -10
index 9600d1ecc518..9e83ed8ec6a6 100644
@@ -4087,18 +4087,9 @@ lpfc_new_io_buf(struct lpfc_hba *phba, int num_to_alloc)
 	LIST_HEAD(post_nblist);
 	LIST_HEAD(nvme_nblist);
 
-	/* Sanity check to ensure our sizing is right for both SCSI and NVME */
-	if (sizeof(struct lpfc_io_buf) > LPFC_COMMON_IO_BUF_SZ) {
-		lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
-				"6426 Common buffer size %zd exceeds %d\n",
-				sizeof(struct lpfc_io_buf),
-				LPFC_COMMON_IO_BUF_SZ);
-		return 0;
-	}
-
 	phba->sli4_hba.io_xri_cnt = 0;
 	for (bcnt = 0; bcnt < num_to_alloc; bcnt++) {
-		lpfc_ncmd = kzalloc(LPFC_COMMON_IO_BUF_SZ, GFP_KERNEL);
+		lpfc_ncmd = kzalloc(sizeof(*lpfc_ncmd), GFP_KERNEL);
 		if (!lpfc_ncmd)
 			break;
 		/*
drivers/scsi/lpfc/lpfc_sli4.h +0 -3
index a4be83d1f37e..0d4882a9e634 100644
@@ -49,9 +49,6 @@
 #define LPFC_FCP_MQ_THRESHOLD_MAX	256
 #define LPFC_FCP_MQ_THRESHOLD_DEF	8
 
-/* Common buffer size to accomidate SCSI and NVME IO buffers */
-#define LPFC_COMMON_IO_BUF_SZ	768
-
 /*
  * Provide the default FCF Record attributes used by the driver
  * when nonFIP mode is configured and there is no other default
Signature · 1 line
2.13.7
#1 lore raw

James,

Quoted 6 lines

The patch d79c9e9d4b3d: "scsi: lpfc: Support dynamic unbounded SGL lists on G7 hardware." from Aug 14, 2019, leads to the following static checker warning:

   drivers/scsi/lpfc/lpfc_init.c:4107 lpfc_new_io_buf()

error: not allocating enough data 784 vs 768

Applied to 5.4/scsi-queue, thanks.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering