From a64c8d1db59f6ca70424356186d279cc6e31213c Mon Sep 17 00:00:00 2001 From: Padmalochan Mohapatra <padmalochan.mohapatra@iopsys.eu> Date: Wed, 3 May 2023 08:15:12 +0000 Subject: [PATCH] libethernet : Fix for counters showing all zero in linux QCM platform's ubus call output --- linux/linux/linux_eth.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/linux/linux/linux_eth.c b/linux/linux/linux_eth.c index e03b776..942d03d 100644 --- a/linux/linux/linux_eth.c +++ b/linux/linux/linux_eth.c @@ -217,11 +217,8 @@ static int linux_get_ethtool_stats(const char *ifname) } struct ethtool_drvinfo drvinfo = {.cmd = ETHTOOL_GDRVINFO}; - struct ifreq req = {.ifr_data = (void *)&drvinfo}; - strncpy(req.ifr_name, ifname, sizeof(req.ifr_name)); - status = ioctl(fd, SIOCETHTOOL, &req); if (status < 0) { @@ -240,7 +237,7 @@ static int linux_get_ethtool_stats(const char *ifname) } stats_size = sizeof(struct ethtool_stats) + (n_stats * sizeof(uint64_t)); - g_linux_stats = malloc(stats_size); + g_linux_stats = (struct ethtool_stats *)calloc(1, stats_size); if (!g_linux_stats) { close(fd); syslog(LOG_ERR, "%s(%d): malloc failed.", -- GitLab