Hi Ahmed,

kernel test robot noticed the following build warnings:

url:    
https://github.com/intel-lab-lkp/linux/commits/Ahmed-Zaki/net-move-ARFS-rmap-management-to-core/20250104-084501
base:   net-next/main
patch link:    
https://lore.kernel.org/r/20250104004314.208259-4-ahmed.zaki%40intel.com
patch subject: [Intel-wired-lan] [PATCH net-next v3 3/6] net: napi: add CPU 
affinity to napi_config
config: i386-randconfig-141-20250104 
(https://download.01.org/0day-ci/archive/20250105/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project 
ab51eccf88f5321e7c60591c5546b254b6afab99)

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
net/core/dev.c:6835 napi_restore_config() warn: variable dereferenced before 
check 'n->config' (see line 6831)
net/core/dev.c:6855 napi_save_config() warn: variable dereferenced before check 
'n->config' (see line 6850)

vim +6835 net/core/dev.c

86e25f40aa1e9e5 Joe Damato     2024-10-11  6829  static void 
napi_restore_config(struct napi_struct *n)
86e25f40aa1e9e5 Joe Damato     2024-10-11  6830  {
86e25f40aa1e9e5 Joe Damato     2024-10-11 @6831         n->defer_hard_irqs = 
n->config->defer_hard_irqs;
86e25f40aa1e9e5 Joe Damato     2024-10-11  6832         n->gro_flush_timeout = 
n->config->gro_flush_timeout;
5dc51ec86df6e22 Martin Karsten 2024-11-09  6833         n->irq_suspend_timeout 
= n->config->irq_suspend_timeout;
                                                                                
 ^^^^^^^^^
These lines all dereference n->config.

d6b43b8a2e5297b Ahmed Zaki     2025-01-03  6834  
d6b43b8a2e5297b Ahmed Zaki     2025-01-03 @6835         if (n->irq > 0 && 
n->config && n->dev->irq_affinity_auto)
                                                                          
^^^^^^^^^
This code assumes it can be NULL

d6b43b8a2e5297b Ahmed Zaki     2025-01-03  6836                 
irq_set_affinity(n->irq, &n->config->affinity_mask);
d6b43b8a2e5297b Ahmed Zaki     2025-01-03  6837  
86e25f40aa1e9e5 Joe Damato     2024-10-11  6838         /* a NAPI ID might be 
stored in the config, if so use it. if not, use
86e25f40aa1e9e5 Joe Damato     2024-10-11  6839          * napi_hash_add to 
generate one for us. It will be saved to the config
86e25f40aa1e9e5 Joe Damato     2024-10-11  6840          * in napi_disable.
86e25f40aa1e9e5 Joe Damato     2024-10-11  6841          */
86e25f40aa1e9e5 Joe Damato     2024-10-11  6842         if (n->config->napi_id)
86e25f40aa1e9e5 Joe Damato     2024-10-11  6843                 
napi_hash_add_with_id(n, n->config->napi_id);
86e25f40aa1e9e5 Joe Damato     2024-10-11  6844         else
86e25f40aa1e9e5 Joe Damato     2024-10-11  6845                 
napi_hash_add(n);
86e25f40aa1e9e5 Joe Damato     2024-10-11  6846  }
86e25f40aa1e9e5 Joe Damato     2024-10-11  6847  
86e25f40aa1e9e5 Joe Damato     2024-10-11  6848  static void 
napi_save_config(struct napi_struct *n)
86e25f40aa1e9e5 Joe Damato     2024-10-11  6849  {
86e25f40aa1e9e5 Joe Damato     2024-10-11 @6850         
n->config->defer_hard_irqs = n->defer_hard_irqs;
86e25f40aa1e9e5 Joe Damato     2024-10-11  6851         
n->config->gro_flush_timeout = n->gro_flush_timeout;
5dc51ec86df6e22 Martin Karsten 2024-11-09  6852         
n->config->irq_suspend_timeout = n->irq_suspend_timeout;
86e25f40aa1e9e5 Joe Damato     2024-10-11  6853         n->config->napi_id = 
n->napi_id;
d6b43b8a2e5297b Ahmed Zaki     2025-01-03  6854  
d6b43b8a2e5297b Ahmed Zaki     2025-01-03 @6855         if (n->irq > 0 && 
n->config && n->dev->irq_affinity_auto)

Same

d6b43b8a2e5297b Ahmed Zaki     2025-01-03  6856                 
irq_set_affinity_notifier(n->irq, NULL);
d6b43b8a2e5297b Ahmed Zaki     2025-01-03  6857  
86e25f40aa1e9e5 Joe Damato     2024-10-11  6858         napi_hash_del(n);
86e25f40aa1e9e5 Joe Damato     2024-10-11  6859  }

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

Reply via email to