Skip to content

Commit 3b19584

Browse files
JoePerchesdavem330
authored andcommitted
i40e: Fix i40e_print_features() VEB mode output
Commit 7fd8954 ("i40e: remove BUG_ON from feature string building") added defective output when I40E_FLAG_VEB_MODE_ENABLED was set in function i40e_print_features. Fix it. Miscellanea: - Remove unnecessary string variable - Add space before not after fixed strings - Use kmalloc not kzalloc - Don't initialize i to 0, use result of first snprintf Reported-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 68e14a4 commit 3b19584

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10290,52 +10290,48 @@ static int i40e_setup_pf_filter_control(struct i40e_pf *pf)
1029010290
static void i40e_print_features(struct i40e_pf *pf)
1029110291
{
1029210292
struct i40e_hw *hw = &pf->hw;
10293-
char *buf, *string;
10294-
int i = 0;
10293+
char *buf;
10294+
int i;
1029510295

10296-
string = kzalloc(INFO_STRING_LEN, GFP_KERNEL);
10297-
if (!string) {
10298-
dev_err(&pf->pdev->dev, "Features string allocation failed\n");
10296+
buf = kmalloc(INFO_STRING_LEN, GFP_KERNEL);
10297+
if (!buf)
1029910298
return;
10300-
}
10301-
10302-
buf = string;
1030310299

10304-
i += snprintf(&buf[i], REMAIN(i), "Features: PF-id[%d] ", hw->pf_id);
10300+
i = snprintf(buf, INFO_STRING_LEN, "Features: PF-id[%d]", hw->pf_id);
1030510301
#ifdef CONFIG_PCI_IOV
10306-
i += snprintf(&buf[i], REMAIN(i), "VFs: %d ", pf->num_req_vfs);
10302+
i += snprintf(&buf[i], REMAIN(i), " VFs: %d", pf->num_req_vfs);
1030710303
#endif
10308-
i += snprintf(&buf[i], REMAIN(i), "VSIs: %d QP: %d RX: %s ",
10304+
i += snprintf(&buf[i], REMAIN(i), " VSIs: %d QP: %d RX: %s",
1030910305
pf->hw.func_caps.num_vsis,
1031010306
pf->vsi[pf->lan_vsi]->num_queue_pairs,
1031110307
pf->flags & I40E_FLAG_RX_PS_ENABLED ? "PS" : "1BUF");
1031210308

1031310309
if (pf->flags & I40E_FLAG_RSS_ENABLED)
10314-
i += snprintf(&buf[i], REMAIN(i), "RSS ");
10310+
i += snprintf(&buf[i], REMAIN(i), " RSS");
1031510311
if (pf->flags & I40E_FLAG_FD_ATR_ENABLED)
10316-
i += snprintf(&buf[i], REMAIN(i), "FD_ATR ");
10312+
i += snprintf(&buf[i], REMAIN(i), " FD_ATR");
1031710313
if (pf->flags & I40E_FLAG_FD_SB_ENABLED) {
10318-
i += snprintf(&buf[i], REMAIN(i), "FD_SB ");
10319-
i += snprintf(&buf[i], REMAIN(i), "NTUPLE ");
10314+
i += snprintf(&buf[i], REMAIN(i), " FD_SB");
10315+
i += snprintf(&buf[i], REMAIN(i), " NTUPLE");
1032010316
}
1032110317
if (pf->flags & I40E_FLAG_DCB_CAPABLE)
10322-
i += snprintf(&buf[i], REMAIN(i), "DCB ");
10318+
i += snprintf(&buf[i], REMAIN(i), " DCB");
1032310319
#if IS_ENABLED(CONFIG_VXLAN)
10324-
i += snprintf(&buf[i], REMAIN(i), "VxLAN ");
10320+
i += snprintf(&buf[i], REMAIN(i), " VxLAN");
1032510321
#endif
1032610322
if (pf->flags & I40E_FLAG_PTP)
10327-
i += snprintf(&buf[i], REMAIN(i), "PTP ");
10323+
i += snprintf(&buf[i], REMAIN(i), " PTP");
1032810324
#ifdef I40E_FCOE
1032910325
if (pf->flags & I40E_FLAG_FCOE_ENABLED)
10330-
i += snprintf(&buf[i], REMAIN(i), "FCOE ");
10326+
i += snprintf(&buf[i], REMAIN(i), " FCOE");
1033110327
#endif
1033210328
if (pf->flags & I40E_FLAG_VEB_MODE_ENABLED)
10333-
i += snprintf(&buf[i], REMAIN(i), "VEPA ");
10329+
i += snprintf(&buf[i], REMAIN(i), " VEB");
1033410330
else
10335-
buf += sprintf(buf, "VEPA ");
10331+
i += snprintf(&buf[i], REMAIN(i), " VEPA");
1033610332

10337-
dev_info(&pf->pdev->dev, "%s\n", string);
10338-
kfree(string);
10333+
dev_info(&pf->pdev->dev, "%s\n", buf);
10334+
kfree(buf);
1033910335
WARN_ON(i > INFO_STRING_LEN);
1034010336
}
1034110337

0 commit comments

Comments
 (0)