diff mbox series

scsi: lpfc: fix sprintf() overflow in lpfc_display_fpin_wwpn()

Message ID 20210916132251.GD25094@kili (mailing list archive)
State Accepted
Headers show
Series scsi: lpfc: fix sprintf() overflow in lpfc_display_fpin_wwpn() | expand

Commit Message

Dan Carpenter Sept. 16, 2021, 1:22 p.m. UTC
This scnprintf() uses the wrong limit.  It should be
"LPFC_FPIN_WWPN_LINE_SZ - len" instead of LPFC_FPIN_WWPN_LINE_SZ.

Fixes: 428569e66fa7 ("scsi: lpfc: Expand FPIN and RDF receive logging")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/scsi/lpfc/lpfc_els.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Smart Sept. 16, 2021, 8:22 p.m. UTC | #1
On 9/16/2021 6:22 AM, Dan Carpenter wrote:
> This scnprintf() uses the wrong limit.  It should be
> "LPFC_FPIN_WWPN_LINE_SZ - len" instead of LPFC_FPIN_WWPN_LINE_SZ.
> 
> Fixes: 428569e66fa7 ("scsi: lpfc: Expand FPIN and RDF receive logging")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>   drivers/scsi/lpfc/lpfc_els.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

looks good. Thank you

Reviewed-by: James Smart <jsmart2021@gmail.com>

-- james
Martin K. Petersen Sept. 22, 2021, 4:44 a.m. UTC | #2
On Thu, 16 Sep 2021 16:22:51 +0300, Dan Carpenter wrote:

> This scnprintf() uses the wrong limit.  It should be
> "LPFC_FPIN_WWPN_LINE_SZ - len" instead of LPFC_FPIN_WWPN_LINE_SZ.
> 
> 

Applied to 5.15/scsi-fixes, thanks!

[1/1] scsi: lpfc: fix sprintf() overflow in lpfc_display_fpin_wwpn()
      https://git.kernel.org/mkp/scsi/c/cdbc16c552f2
diff mbox series

Patch

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index f3fc79b99165..052c0e5b1119 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -9387,7 +9387,7 @@  lpfc_display_fpin_wwpn(struct lpfc_hba *phba, __be64 *wwnlist, u32 cnt)
 		/* Extract the next WWPN from the payload */
 		wwn = *wwnlist++;
 		wwpn = be64_to_cpu(wwn);
-		len += scnprintf(buf + len, LPFC_FPIN_WWPN_LINE_SZ,
+		len += scnprintf(buf + len, LPFC_FPIN_WWPN_LINE_SZ - len,
 				 " %016llx", wwpn);
 
 		/* Log a message if we are on the last WWPN