Skip to contentSkip to conversation

scsi: lpfc: use correct scnprintf() limit

PATCH Applied Dan Carpenter 3 participants 3 messages Sep 16, 2021 – Sep 22, 2021

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

PATCH 1/1 scsi: lpfc: use correct scnprintf() limit

The limit should be "PAGE_SIZE - len" instead of "PAGE_SIZE". We're not going to hit the limit so this fix will not affect runtime.

Fixes 5b9e70b22cc5 ("scsi: lpfc: raise sg count for nvme to use available sg resources")
---
 drivers/scsi/lpfc/lpfc_attr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_attr.c +2 -1
index b35bf70a8c0d..1e5a30eb04de 100644
@@ -6204,7 +6204,8 @@ lpfc_sg_seg_cnt_show(struct device *dev, struct device_attribute *attr,
 	len = scnprintf(buf, PAGE_SIZE, "SGL sz: %d  total SGEs: %d\n",
 		       phba->cfg_sg_dma_buf_size, phba->cfg_total_seg_cnt);
 
-	len += scnprintf(buf + len, PAGE_SIZE, "Cfg: %d  SCSI: %d  NVME: %d\n",
+	len += scnprintf(buf + len, PAGE_SIZE - len,
+			"Cfg: %d  SCSI: %d  NVME: %d\n",
 			phba->cfg_sg_seg_cnt, phba->cfg_scsi_seg_cnt,
 			phba->cfg_nvme_seg_cnt);
 	return len;
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dan Carpenter

The limit should be "PAGE_SIZE - len" instead of "PAGE_SIZE". We're not going to hit the limit so this fix will not affect runtime.

Fixes 5b9e70b22cc5 ("scsi: lpfc: raise sg count for nvme to use available sg resources")
---
  drivers/scsi/lpfc/lpfc_attr.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

looks good. Thank you

-- james