]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
scsi: lpfc: Use correct scnprintf() limit
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 16 Sep 2021 13:23:31 +0000 (16:23 +0300)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 5 Nov 2021 09:20:23 +0000 (10:20 +0100)
BugLink: https://bugs.launchpad.net/bugs/1949640
[ Upstream commit 6dacc371b77f473770ec646e220303a84fe96c11 ]

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.

Link: https://lore.kernel.org/r/20210916132331.GE25094@kili
Fixes: 5b9e70b22cc5 ("scsi: lpfc: raise sg count for nvme to use available sg resources")
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/scsi/lpfc/lpfc_attr.c

index 243513925e90a0d35a4e665a6a6a8044c39161c2..c1894c950a1c6067109ae860a7350bcb14b2b451 100644 (file)
@@ -6010,7 +6010,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;