mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
net: ena: Changes around strscpy calls
strscpy copies as much of the string as possible, meaning that the destination string will be truncated in case of no space. As this is a non-critical error in our case, adding a debug level print for indication. This patch also removes a -1 which was added to ensure enough space for NUL, but strscpy destination string is guaranteed to be NUL-terminted, therefore, the -1 is not needed. Signed-off-by: David Arinzon <darinzon@amazon.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/20240512134637.25299-5-darinzon@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
b37b98a3a0
commit
97776caf6c
|
|
@ -460,10 +460,18 @@ static void ena_get_drvinfo(struct net_device *dev,
|
|||
struct ethtool_drvinfo *info)
|
||||
{
|
||||
struct ena_adapter *adapter = netdev_priv(dev);
|
||||
ssize_t ret = 0;
|
||||
|
||||
strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
|
||||
strscpy(info->bus_info, pci_name(adapter->pdev),
|
||||
sizeof(info->bus_info));
|
||||
ret = strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
|
||||
if (ret < 0)
|
||||
netif_dbg(adapter, drv, dev,
|
||||
"module name will be truncated, status = %zd\n", ret);
|
||||
|
||||
ret = strscpy(info->bus_info, pci_name(adapter->pdev),
|
||||
sizeof(info->bus_info));
|
||||
if (ret < 0)
|
||||
netif_dbg(adapter, drv, dev,
|
||||
"bus info will be truncated, status = %zd\n", ret);
|
||||
}
|
||||
|
||||
static void ena_get_ringparam(struct net_device *netdev,
|
||||
|
|
|
|||
|
|
@ -2703,6 +2703,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev, struct pci_dev *pd
|
|||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct ena_admin_host_info *host_info;
|
||||
ssize_t ret;
|
||||
int rc;
|
||||
|
||||
/* Allocate only the host info */
|
||||
|
|
@ -2717,11 +2718,19 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev, struct pci_dev *pd
|
|||
host_info->bdf = pci_dev_id(pdev);
|
||||
host_info->os_type = ENA_ADMIN_OS_LINUX;
|
||||
host_info->kernel_ver = LINUX_VERSION_CODE;
|
||||
strscpy(host_info->kernel_ver_str, utsname()->version,
|
||||
sizeof(host_info->kernel_ver_str) - 1);
|
||||
ret = strscpy(host_info->kernel_ver_str, utsname()->version,
|
||||
sizeof(host_info->kernel_ver_str));
|
||||
if (ret < 0)
|
||||
dev_dbg(dev,
|
||||
"kernel version string will be truncated, status = %zd\n", ret);
|
||||
|
||||
host_info->os_dist = 0;
|
||||
strscpy(host_info->os_dist_str, utsname()->release,
|
||||
sizeof(host_info->os_dist_str));
|
||||
ret = strscpy(host_info->os_dist_str, utsname()->release,
|
||||
sizeof(host_info->os_dist_str));
|
||||
if (ret < 0)
|
||||
dev_dbg(dev,
|
||||
"OS distribution string will be truncated, status = %zd\n", ret);
|
||||
|
||||
host_info->driver_version =
|
||||
(DRV_MODULE_GEN_MAJOR) |
|
||||
(DRV_MODULE_GEN_MINOR << ENA_ADMIN_HOST_INFO_MINOR_SHIFT) |
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user