Re: [PATCH] topology/sysfs: Fix allnoconfig build breakage.

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

 



On Thu, Apr 21, 2022 at 08:45:34AM -0700, Luck, Tony wrote:
> drivers/base/topology.c: In function 'topology_is_visible':
> drivers/base/topology.c:158:24: warning: unused variable 'dev' [-Wunused-variable]
>   158 |         struct device *dev = kobj_to_dev(kobj);
> 
> This is because the topology_ppin(dev->id) macro expands to:
> 
> 	(cpu_data(dev->id).ppin)
> 
> and with CONFIG_SMP=n the cpu_data() macro expands to boot_cpu_data
> (ignoring its argument) with the end result:
> 
> 	boot_cpu_data.ppin
> 
> My CPP-fu wasn't up to a modification to topology_ppin(), so I added a
> (probably redundant) check for "dev" being a NULL pointer.
> 
> Fixes: c3702a746ff5 ("topology/sysfs: Hide PPIN on systems that do not support it.")
> Reported-by: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
> Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
> 
> ---
> Better fixes with clever CPP macro tricks gratefully welcomed
> ---
>  drivers/base/topology.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/topology.c b/drivers/base/topology.c
> index 706dbf8bf249..31fae51fd340 100644
> --- a/drivers/base/topology.c
> +++ b/drivers/base/topology.c
> @@ -157,7 +157,7 @@ static umode_t topology_is_visible(struct kobject *kobj,
>  {
>  	struct device *dev = kobj_to_dev(kobj);
>  
> -	if (attr == &dev_attr_ppin.attr && !topology_ppin(dev->id))
> +	if (!dev || (attr == &dev_attr_ppin.attr && !topology_ppin(dev->id)))

!dev is impossible to ever hit, that's the sign that the code is wrong
and needs to be fixed :(

Sorry, this is not going to be an acceptable change.

greg k-h



[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux