Re: [External] Re: [pm:bleeding-edge 8612/8615] drivers/acpi/platform_profile.c:147:24: warning: address of array 'pprof->choices' will always evaluate to 'true'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hans

On 27/12/2020 06:56, Hans de Goede wrote:
> Hi,
> 
> On 12/27/20 6:11 AM, kernel test robot wrote:
>> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git bleeding-edge
>> head:   a33520709645543f108361fe21fa9434a351c4e9
>> commit: 8c9b909fb1282e43792433e6c1cba125ccfc6201 [8612/8615] ACPI: platform-profile: Add platform profile support
>> config: x86_64-randconfig-a015-20201221 (attached as .config)
>> compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project cee1e7d14f4628d6174b33640d502bff3b54ae45)
>> reproduce (this is a W=1 build):
>>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>         chmod +x ~/bin/make.cross
>>         # install x86_64 cross compiling tool for clang build
>>         # apt-get install binutils-x86-64-linux-gnu
>>         # https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?id=8c9b909fb1282e43792433e6c1cba125ccfc6201
>>         git remote add pm https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
>>         git fetch --no-tags pm bleeding-edge
>>         git checkout 8c9b909fb1282e43792433e6c1cba125ccfc6201
>>         # save the attached .config to linux build tree
>>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
>>
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>>
>> All warnings (new ones prefixed by >>):
>>
>>>> drivers/acpi/platform_profile.c:147:24: warning: address of array 'pprof->choices' will always evaluate to 'true' [-Wpointer-bool-conversion]
>>            if (!pprof || !pprof->choices || !pprof->profile_set ||
>>                          ~~~~~~~~^~~~~~~
>>    1 warning generated.
> 
> 
> Ah, this is caused by changing choices from a single long to:
> 
> 	unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
> 
> So that we can use for_each_set_bit and are future proof for more then
> 32 profiles.
> 
> To fix this the check should be changed into this (untested):
> 
> #include <linux/bitmap.h>
> 
> 	if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) ||
> 	    !pprof->profile_set || !pprof->profile_get) {
> 		mutex_unlock(&profile_lock);
> 		return -EINVAL;
> 	}
> 
> Mark can you provide a (tested) patch for this?
> 
> Regards,
> 
> Hans
> 
Will do!

Mark

> 
> 
> 
> 
> 
> 
> 
>>
>>
>> vim +147 drivers/acpi/platform_profile.c
>>
>>    134	
>>    135	int platform_profile_register(const struct platform_profile_handler *pprof)
>>    136	{
>>    137		int err;
>>    138	
>>    139		mutex_lock(&profile_lock);
>>    140		/* We can only have one active profile */
>>    141		if (cur_profile) {
>>    142			mutex_unlock(&profile_lock);
>>    143			return -EEXIST;
>>    144		}
>>    145	
>>    146		/* Sanity check the profile handler field are set */
>>  > 147		if (!pprof || !pprof->choices || !pprof->profile_set ||
>>    148				!pprof->profile_get) {
>>    149			mutex_unlock(&profile_lock);
>>    150			return -EINVAL;
>>    151		}
>>    152	
>>    153		err = sysfs_create_group(acpi_kobj, &platform_profile_group);
>>    154		if (err) {
>>    155			mutex_unlock(&profile_lock);
>>    156			return err;
>>    157		}
>>    158	
>>    159		cur_profile = pprof;
>>    160		mutex_unlock(&profile_lock);
>>    161		return 0;
>>    162	}
>>    163	EXPORT_SYMBOL_GPL(platform_profile_register);
>>    164	
>>
>> ---
>> 0-DAY CI Kernel Test Service, Intel Corporation
>> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
>>
> 



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux