Skip to content

Commit 413ae54

Browse files
tiwaidavem330
authored andcommitted
net: nfp: Use scnprintf() for avoiding potential buffer overflow
Since snprintf() returns the would-be-output size instead of the actual output size, the succeeding calls may go beyond the given buffer limit. Fix it by replacing with scnprintf(). Reviewed-by: Simon Horman <[email protected]> Cc: "David S . Miller" <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: [email protected] To: [email protected] Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a34860 commit 413ae54

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
616616
if (bar->iomem) {
617617
int pf;
618618

619-
msg += snprintf(msg, end - msg, "0.0: General/MSI-X SRAM, ");
619+
msg += scnprintf(msg, end - msg, "0.0: General/MSI-X SRAM, ");
620620
atomic_inc(&bar->refcnt);
621621
bars_free--;
622622

@@ -661,7 +661,7 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
661661

662662
/* Configure, and lock, BAR0.1 for PCIe XPB (MSI-X PBA) */
663663
bar = &nfp->bar[1];
664-
msg += snprintf(msg, end - msg, "0.1: PCIe XPB/MSI-X PBA, ");
664+
msg += scnprintf(msg, end - msg, "0.1: PCIe XPB/MSI-X PBA, ");
665665
atomic_inc(&bar->refcnt);
666666
bars_free--;
667667

@@ -680,8 +680,8 @@ static int enable_bars(struct nfp6000_pcie *nfp, u16 interface)
680680
bar->iomem = ioremap(nfp_bar_resource_start(bar),
681681
nfp_bar_resource_len(bar));
682682
if (bar->iomem) {
683-
msg += snprintf(msg, end - msg,
684-
"0.%d: Explicit%d, ", 4 + i, i);
683+
msg += scnprintf(msg, end - msg,
684+
"0.%d: Explicit%d, ", 4 + i, i);
685685
atomic_inc(&bar->refcnt);
686686
bars_free--;
687687

0 commit comments

Comments
 (0)