BCC: l...@intel.com
CC: kbuild-...@lists.01.org
CC: linux-ker...@vger.kernel.org
TO: Deren Wu <deren...@mediatek.com>
CC: Felix Fietkau <n...@nbd.name>
CC: Sean Wang <sean.w...@mediatek.com>
CC: Quan Zhou <quan.z...@mediatek.com>
CC: Ming Yen Hsieh <mingyen.hs...@mediatek.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   568035b01cfb107af8d2e4bd2fb9aea22cf5b868
commit: f965333e491e36adb0fa91e389fba8685b704fb6 mt76: mt7921: introduce ACPI 
SAR support
date:   5 weeks ago
:::::: branch date: 13 hours ago
:::::: commit date: 5 weeks ago
config: ia64-randconfig-m031-20220814 
(https://download.01.org/0day-ci/archive/20220815/202208151913.evjlcufv-...@intel.com/config)
compiler: ia64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

smatch warnings:
drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c:57 mt7921_acpi_read() 
error: dereferencing freed memory 'sar_root'

vim +/sar_root +57 drivers/net/wireless/mediatek/mt76/mt7921/acpi_sar.c

f965333e491e36 Deren Wu 2022-05-20   6  
f965333e491e36 Deren Wu 2022-05-20   7  static int
f965333e491e36 Deren Wu 2022-05-20   8  mt7921_acpi_read(struct mt7921_dev 
*dev, u8 *method, u8 **tbl, u32 *len)
f965333e491e36 Deren Wu 2022-05-20   9  {
f965333e491e36 Deren Wu 2022-05-20  10          struct acpi_buffer buf = { 
ACPI_ALLOCATE_BUFFER, NULL };
f965333e491e36 Deren Wu 2022-05-20  11          union acpi_object *sar_root, 
*sar_unit;
f965333e491e36 Deren Wu 2022-05-20  12          struct mt76_dev *mdev = 
&dev->mt76;
f965333e491e36 Deren Wu 2022-05-20  13          acpi_handle root, handle;
f965333e491e36 Deren Wu 2022-05-20  14          acpi_status status;
f965333e491e36 Deren Wu 2022-05-20  15          u32 i = 0;
f965333e491e36 Deren Wu 2022-05-20  16  
f965333e491e36 Deren Wu 2022-05-20  17          root = ACPI_HANDLE(mdev->dev);
f965333e491e36 Deren Wu 2022-05-20  18          if (!root)
f965333e491e36 Deren Wu 2022-05-20  19                  return -EOPNOTSUPP;
f965333e491e36 Deren Wu 2022-05-20  20  
f965333e491e36 Deren Wu 2022-05-20  21          status = acpi_get_handle(root, 
method, &handle);
f965333e491e36 Deren Wu 2022-05-20  22          if (ACPI_FAILURE(status))
f965333e491e36 Deren Wu 2022-05-20  23                  return -EIO;
f965333e491e36 Deren Wu 2022-05-20  24  
f965333e491e36 Deren Wu 2022-05-20  25          status = 
acpi_evaluate_object(handle, NULL, NULL, &buf);
f965333e491e36 Deren Wu 2022-05-20  26          if (ACPI_FAILURE(status))
f965333e491e36 Deren Wu 2022-05-20  27                  return -EIO;
f965333e491e36 Deren Wu 2022-05-20  28  
f965333e491e36 Deren Wu 2022-05-20  29          sar_root = buf.pointer;
f965333e491e36 Deren Wu 2022-05-20  30          if (sar_root->type != 
ACPI_TYPE_PACKAGE ||
f965333e491e36 Deren Wu 2022-05-20  31              sar_root->package.count < 4 
||
f965333e491e36 Deren Wu 2022-05-20  32              
sar_root->package.elements[0].type != ACPI_TYPE_INTEGER) {
f965333e491e36 Deren Wu 2022-05-20  33                  dev_err(mdev->dev, "sar 
cnt = %d\n",
f965333e491e36 Deren Wu 2022-05-20  34                          
sar_root->package.count);
f965333e491e36 Deren Wu 2022-05-20  35                  goto free;
f965333e491e36 Deren Wu 2022-05-20  36          }
f965333e491e36 Deren Wu 2022-05-20  37  
f965333e491e36 Deren Wu 2022-05-20  38          if (!*tbl) {
f965333e491e36 Deren Wu 2022-05-20  39                  *tbl = 
devm_kzalloc(mdev->dev, sar_root->package.count,
f965333e491e36 Deren Wu 2022-05-20  40                                      
GFP_KERNEL);
f965333e491e36 Deren Wu 2022-05-20  41                  if (!*tbl)
f965333e491e36 Deren Wu 2022-05-20  42                          goto free;
f965333e491e36 Deren Wu 2022-05-20  43          }
f965333e491e36 Deren Wu 2022-05-20  44          if (len)
f965333e491e36 Deren Wu 2022-05-20  45                  *len = 
sar_root->package.count;
f965333e491e36 Deren Wu 2022-05-20  46  
f965333e491e36 Deren Wu 2022-05-20  47          for (i = 0; i < 
sar_root->package.count; i++) {
f965333e491e36 Deren Wu 2022-05-20  48                  sar_unit = 
&sar_root->package.elements[i];
f965333e491e36 Deren Wu 2022-05-20  49  
f965333e491e36 Deren Wu 2022-05-20  50                  if (sar_unit->type != 
ACPI_TYPE_INTEGER)
f965333e491e36 Deren Wu 2022-05-20  51                          break;
f965333e491e36 Deren Wu 2022-05-20  52                  *(*tbl + i) = 
(u8)sar_unit->integer.value;
f965333e491e36 Deren Wu 2022-05-20  53          }
f965333e491e36 Deren Wu 2022-05-20  54  free:
f965333e491e36 Deren Wu 2022-05-20  55          kfree(sar_root);
f965333e491e36 Deren Wu 2022-05-20  56  
f965333e491e36 Deren Wu 2022-05-20 @57          return (i == 
sar_root->package.count) ? 0 : -EINVAL;
f965333e491e36 Deren Wu 2022-05-20  58  }
f965333e491e36 Deren Wu 2022-05-20  59  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to