Skip to contentSkip to conversation

drivers/scsi/mpt3sas/mpt3sas_scsih.c:10244 _scsih_scan_for_devices_after_reset() warn: possible memory leak of 'volume_pg0'

PATCH New Dan Carpenter 1 participant 1 message Feb 27, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 216/226 drivers/scsi/mpt3sas/mpt3sas_scsih.c:10244 _scsih_scan_for_devices_after_reset() warn: possible memory leak of 'volume_pg0'

tree:   https://git.linaro.org/people/lee.jones/linux.git tb-fix-w1-warnings
head:   49fe493a5f7cebaec70944df919df3350d4cb520
commit: a5ab8c19b6f704742e181af8b429a208e9a0e393 [216/226] fixup! scsi: mpt3sas: mpt3sas_scs: Move a little data from the stack onto the heap
config: xtensa-randconfig-m031-20210227 (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
drivers/scsi/mpt3sas/mpt3sas_scsih.c:10244 _scsih_scan_for_devices_after_reset() warn: possible memory leak of 'volume_pg0'

Old smatch warnings:
drivers/scsi/mpt3sas/mpt3sas_scsih.c:6865 _scsih_expander_add() warn: returning -1 instead of -ENOMEM is sloppy drivers/scsi/mpt3sas/mpt3sas_scsih.c:6885 _scsih_expander_add() warn: missing error code 'rc' drivers/scsi/mpt3sas/mpt3sas_scsih.c:10650 _mpt3sas_fw_work() warn: inconsistent indenting

vim +/volume_pg0 +10244 drivers/scsi/mpt3sas/mpt3sas_scsih.c

f92363d12359498f Sreekanth Reddy          2012-11-30  10216  static void
f92363d12359498f Sreekanth Reddy          2012-11-30  10217  _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
f92363d12359498f Sreekanth Reddy          2012-11-30  10218  {
f92363d12359498f Sreekanth Reddy          2012-11-30  10219  	Mpi2ExpanderPage0_t expander_pg0;
f92363d12359498f Sreekanth Reddy          2012-11-30  10220  	Mpi2SasDevicePage0_t sas_device_pg0;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31  10221  	Mpi26PCIeDevicePage0_t pcie_device_pg0;
16dc4b15325d1db7 Lee Jones                2021-02-25  10222  	Mpi2RaidVolPage1_t *volume_pg1;
16dc4b15325d1db7 Lee Jones                2021-02-25  10223  	Mpi2RaidVolPage0_t *volume_pg0;
f92363d12359498f Sreekanth Reddy          2012-11-30  10224  	Mpi2RaidPhysDiskPage0_t pd_pg0;
f92363d12359498f Sreekanth Reddy          2012-11-30  10225  	Mpi2EventIrConfigElement_t element;
f92363d12359498f Sreekanth Reddy          2012-11-30  10226  	Mpi2ConfigReply_t mpi_reply;
e2f0cdf7525353d8 Sreekanth Reddy          2020-10-27  10227  	u8 phys_disk_num, port_id;
f92363d12359498f Sreekanth Reddy          2012-11-30  10228  	u16 ioc_status;
f92363d12359498f Sreekanth Reddy          2012-11-30  10229  	u16 handle, parent_handle;
f92363d12359498f Sreekanth Reddy          2012-11-30  10230  	u64 sas_address;
f92363d12359498f Sreekanth Reddy          2012-11-30  10231  	struct _sas_device *sas_device;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31  10232  	struct _pcie_device *pcie_device;
f92363d12359498f Sreekanth Reddy          2012-11-30  10233  	struct _sas_node *expander_device;
f92363d12359498f Sreekanth Reddy          2012-11-30  10234  	static struct _raid_device *raid_device;
f92363d12359498f Sreekanth Reddy          2012-11-30  10235  	u8 retry_count;
f92363d12359498f Sreekanth Reddy          2012-11-30  10236  	unsigned long flags;
f92363d12359498f Sreekanth Reddy          2012-11-30  10237  
16dc4b15325d1db7 Lee Jones                2021-02-25  10238  	volume_pg0 = kzalloc(sizeof(*volume_pg0), GFP_KERNEL);
16dc4b15325d1db7 Lee Jones                2021-02-25  10239  	if (!volume_pg0)
16dc4b15325d1db7 Lee Jones                2021-02-25  10240  		return;
16dc4b15325d1db7 Lee Jones                2021-02-25  10241  
16dc4b15325d1db7 Lee Jones                2021-02-25  10242  	volume_pg1 = kzalloc(sizeof(*volume_pg1), GFP_KERNEL);
16dc4b15325d1db7 Lee Jones                2021-02-25  10243  	if (!volume_pg1)

16dc4b15325d1db7 Lee Jones 2021-02-25 @10244 return;

kfree(volume_pg0) before returning?

16dc4b15325d1db7 Lee Jones                2021-02-25  10245  
919d8a3f3fef9910 Joe Perches              2018-09-17  10246  	ioc_info(ioc, "scan devices: start\n");

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org