Re: [PATCH v2 06/10] memory: scrub: Add scrub driver supports configuring memory scrubbers in the system

From: Dan Carpenter
Date: Wed Nov 22 2023 - 05:43:09 EST


Hi,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/shiju-jose-huawei-com/cxl-mbox-Add-GET_SUPPORTED_FEATURES-mailbox-command/20231121-182247
base: linus/master
patch link: https://lore.kernel.org/r/20231121101844.1161-7-shiju.jose%40huawei.com
patch subject: [PATCH v2 06/10] memory: scrub: Add scrub driver supports configuring memory scrubbers in the system
config: powerpc-randconfig-r071-20231122 (https://download.01.org/0day-ci/archive/20231122/202311221028.fsptP2bp-lkp@xxxxxxxxx/config)
compiler: powerpc-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231122/202311221028.fsptP2bp-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>
| Closes: https://lore.kernel.org/r/202311221028.fsptP2bp-lkp@xxxxxxxxx/

smatch warnings:
drivers/memory/scrub/memory-scrub.c:71 scrub_dev_attr_is_visible() warn: this array is probably non-NULL. 'scrub_dev->name'

vim +71 drivers/memory/scrub/memory-scrub.c

248ee451a36346 Shiju Jose 2023-11-21 65 static umode_t scrub_dev_attr_is_visible(struct kobject *kobj,
248ee451a36346 Shiju Jose 2023-11-21 66 struct attribute *attr, int n)
248ee451a36346 Shiju Jose 2023-11-21 67 {
248ee451a36346 Shiju Jose 2023-11-21 68 struct device *dev = kobj_to_dev(kobj);
248ee451a36346 Shiju Jose 2023-11-21 69 struct scrub_device *scrub_dev = to_scrub_device(dev);
248ee451a36346 Shiju Jose 2023-11-21 70
248ee451a36346 Shiju Jose 2023-11-21 @71 if (attr == &dev_attr_name.attr && scrub_dev->name == NULL)

I wrote this check 12 years ago and it's crap. scrub_dev->name is the
first struct member so it's the same as same as "scrub_dev". However
to_scrub_device() can't return NULL so this check is dead code.

248ee451a36346 Shiju Jose 2023-11-21 72 return 0;
248ee451a36346 Shiju Jose 2023-11-21 73
248ee451a36346 Shiju Jose 2023-11-21 74 return attr->mode;
248ee451a36346 Shiju Jose 2023-11-21 75 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki