mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-15 18:34:47 +08:00
i40e: 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(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
parent
394f9ebf92
commit
c28481a88c
@ -14486,29 +14486,29 @@ static void i40e_print_features(struct i40e_pf *pf)
|
||||
|
||||
i = snprintf(buf, INFO_STRING_LEN, "Features: PF-id[%d]", hw->pf_id);
|
||||
#ifdef CONFIG_PCI_IOV
|
||||
i += snprintf(&buf[i], REMAIN(i), " VFs: %d", pf->num_req_vfs);
|
||||
i += scnprintf(&buf[i], REMAIN(i), " VFs: %d", pf->num_req_vfs);
|
||||
#endif
|
||||
i += snprintf(&buf[i], REMAIN(i), " VSIs: %d QP: %d",
|
||||
i += scnprintf(&buf[i], REMAIN(i), " VSIs: %d QP: %d",
|
||||
pf->hw.func_caps.num_vsis,
|
||||
pf->vsi[pf->lan_vsi]->num_queue_pairs);
|
||||
if (pf->flags & I40E_FLAG_RSS_ENABLED)
|
||||
i += snprintf(&buf[i], REMAIN(i), " RSS");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " RSS");
|
||||
if (pf->flags & I40E_FLAG_FD_ATR_ENABLED)
|
||||
i += snprintf(&buf[i], REMAIN(i), " FD_ATR");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " FD_ATR");
|
||||
if (pf->flags & I40E_FLAG_FD_SB_ENABLED) {
|
||||
i += snprintf(&buf[i], REMAIN(i), " FD_SB");
|
||||
i += snprintf(&buf[i], REMAIN(i), " NTUPLE");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " FD_SB");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " NTUPLE");
|
||||
}
|
||||
if (pf->flags & I40E_FLAG_DCB_CAPABLE)
|
||||
i += snprintf(&buf[i], REMAIN(i), " DCB");
|
||||
i += snprintf(&buf[i], REMAIN(i), " VxLAN");
|
||||
i += snprintf(&buf[i], REMAIN(i), " Geneve");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " DCB");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " VxLAN");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " Geneve");
|
||||
if (pf->flags & I40E_FLAG_PTP)
|
||||
i += snprintf(&buf[i], REMAIN(i), " PTP");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " PTP");
|
||||
if (pf->flags & I40E_FLAG_VEB_MODE_ENABLED)
|
||||
i += snprintf(&buf[i], REMAIN(i), " VEB");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " VEB");
|
||||
else
|
||||
i += snprintf(&buf[i], REMAIN(i), " VEPA");
|
||||
i += scnprintf(&buf[i], REMAIN(i), " VEPA");
|
||||
|
||||
dev_info(&pf->pdev->dev, "%s\n", buf);
|
||||
kfree(buf);
|
||||
|
Loading…
Reference in New Issue
Block a user