[jpirko-mlxsw:petrm_soft_counters 7/8] net/core/dev.c:8395 netdev_offload_xstats_hw_stats_enable() error: uninitialized symbol 'stats'.
From: Dan Carpenter
Date: Mon Nov 29 2021 - 06:16:38 EST
tree: https://github.com/jpirko/linux_mlxsw petrm_soft_counters
head: 59d158395664dab1c1164364d6ee57aaaad44b96
commit: d35d00a6d28ff7a34145438df3a2b39abd00edc3 [7/8] wip
config: x86_64-randconfig-m001-20211117 (https://download.01.org/0day-ci/archive/20211126/202111260203.hEYHxybc-lkp@xxxxxxxxx/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
New smatch warnings:
net/core/dev.c:8395 netdev_offload_xstats_hw_stats_enable() error: uninitialized symbol 'stats'.
Old smatch warnings:
net/core/dev.c:6922 napi_disable() error: uninitialized symbol 'new'.
vim +/stats +8395 net/core/dev.c
453f3cd9e64f05f Petr Machata 2021-10-29 8363 int netdev_offload_xstats_hw_stats_enable(struct net_device *dev,
453f3cd9e64f05f Petr Machata 2021-10-29 8364 u32 req_hw_stats,
a8a72b09197b260 Petr Machata 2021-10-22 8365 struct netlink_ext_ack *extack)
a8a72b09197b260 Petr Machata 2021-10-22 8366 {
a8a72b09197b260 Petr Machata 2021-10-22 8367 struct netdev_notifier_offload_xstats_info info = {
a8a72b09197b260 Petr Machata 2021-10-22 8368 .info.dev = dev,
a8a72b09197b260 Petr Machata 2021-10-22 8369 .info.extack = extack,
453f3cd9e64f05f Petr Machata 2021-10-29 8370 .cmd = NETDEV_OFFLOAD_XSTATS_CMD_ENABLE,
7f3ca7ed5c4b775 Petr Machata 2021-11-03 8371 .hw_stats = req_hw_stats,
a8a72b09197b260 Petr Machata 2021-10-22 8372 };
453f3cd9e64f05f Petr Machata 2021-10-29 8373 struct rtnl_link_stats64 *stats;
a8a72b09197b260 Petr Machata 2021-10-22 8374 int err;
a8a72b09197b260 Petr Machata 2021-10-22 8375 int rc;
a8a72b09197b260 Petr Machata 2021-10-22 8376
d35d00a6d28ff7a Petr Machata 2021-11-12 8377 if (!dev->offload_hw_stats) {
d35d00a6d28ff7a Petr Machata 2021-11-12 8378 dev->offload_hw_stats = kzalloc(sizeof(*dev->offload_hw_stats),
d35d00a6d28ff7a Petr Machata 2021-11-12 8379 GFP_KERNEL);
d35d00a6d28ff7a Petr Machata 2021-11-12 8380 if (!dev->offload_hw_stats)
453f3cd9e64f05f Petr Machata 2021-10-29 8381 return -ENOMEM;
d35d00a6d28ff7a Petr Machata 2021-11-12 8382 }
453f3cd9e64f05f Petr Machata 2021-10-29 8383
453f3cd9e64f05f Petr Machata 2021-10-29 8384 rc = call_netdevice_notifiers_info(NETDEV_OFFLOAD_XSTATS_CMD,
a8a72b09197b260 Petr Machata 2021-10-22 8385 &info.info);
a8a72b09197b260 Petr Machata 2021-10-22 8386 err = notifier_to_errno(rc);
453f3cd9e64f05f Petr Machata 2021-10-29 8387 if (err)
453f3cd9e64f05f Petr Machata 2021-10-29 8388 // xxx note we need a way to roll back if the notifier chain
453f3cd9e64f05f Petr Machata 2021-10-29 8389 // fails midway through
453f3cd9e64f05f Petr Machata 2021-10-29 8390 goto free_stats;
453f3cd9e64f05f Petr Machata 2021-10-29 8391
453f3cd9e64f05f Petr Machata 2021-10-29 8392 return 0;
453f3cd9e64f05f Petr Machata 2021-10-29 8393
453f3cd9e64f05f Petr Machata 2021-10-29 8394 free_stats:
453f3cd9e64f05f Petr Machata 2021-10-29 @8395 kfree(stats);
^^^^^
Never initialized. Delete this variable.
a8a72b09197b260 Petr Machata 2021-10-22 8396 return err;
a8a72b09197b260 Petr Machata 2021-10-22 8397 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx