Re: [PATCH v3 06/10] hwmon: (fam15h_power) Add compute unit accumulated power
From: Huang Rui
Date: Sun Nov 01 2015 - 23:46:48 EST
On Fri, Oct 30, 2015 at 06:33:42PM +0800, kbuild test robot wrote:
> Hi Huang,
>
> [auto build test WARNING on hwmon/hwmon-next -- if it's inappropriate base, please suggest rules for selecting the more suitable base]
>
> url: https://github.com/0day-ci/linux/commits/Huang-Rui/hwmon-fam15h_power-Introduce-an-accumulated-power-reporting-algorithm/20151030-181426
> config: x86_64-randconfig-x012-10300134 (attached as .config)
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64
>
> Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
> http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
>
> All warnings (new ones prefixed by >>):
>
> In file included from arch/x86/include/asm/cpumask.h:4:0,
> from arch/x86/include/asm/msr.h:10,
> from arch/x86/include/asm/processor.h:20,
> from arch/x86/include/asm/atomic.h:6,
> from include/linux/atomic.h:4,
> from include/linux/debug_locks.h:5,
> from include/linux/lockdep.h:23,
> from include/linux/spinlock_types.h:18,
> from include/linux/mutex.h:15,
> from include/linux/kernfs.h:13,
> from include/linux/sysfs.h:15,
> from include/linux/kobject.h:21,
> from include/linux/device.h:17,
> from include/linux/hwmon-sysfs.h:23,
> from drivers/hwmon/fam15h_power.c:23:
> drivers/hwmon/fam15h_power.c: In function 'fam15h_power_probe':
> >> include/linux/cpumask.h:24:29: warning: 'res_mask' may be used uninitialized in this function [-Wmaybe-uninitialized]
> #define cpumask_bits(maskp) ((maskp)->bits)
> ^
> drivers/hwmon/fam15h_power.c:145:32: note: 'res_mask' was declared here
> cpumask_var_t mask, tmp_mask, res_mask;
> ^
Thank you to capture it! That's because my machine doesn't enable
CONFIG_CPUMASK_OFFSTACK. So I didn't find this issue before. :)
It needs to allocate res_mask like below:
---
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 71c9e6c..499776b 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -172,6 +172,10 @@ static int read_registers(struct fam15h_power_data *data)
if (!ret)
return -ENOMEM;
+ ret = zalloc_cpumask_var(&res_mask, GFP_KERNEL);
+ if (!ret)
+ return -ENOMEM;
+
get_online_cpus();
this_cpu = get_cpu();
@@ -199,6 +203,7 @@ static int read_registers(struct fam15h_power_data *data)
put_cpu();
put_online_cpus();
+ free_cpumask_var(res_mask);
free_cpumask_var(tmp_mask);
free_cpumask_var(mask);
---
Thanks,
Rui
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/