* [lee-linaro:tb-fix-w1-warnings 216/226] drivers/scsi/mpt3sas/mpt3sas_scsih.c:10244 _scsih_scan_for_devices_after_reset() warn: possible memory leak of 'volume_pg0'
@ 2021-02-27 1:26 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-02-27 1:26 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 28206 bytes --]
CC: kbuild-all(a)lists.01.org
TO: Lee Jones <lee.jones@linaro.org>
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
:::::: branch date: 9 hours ago
:::::: commit date: 11 hours ago
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
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
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 10211
f92363d12359498f Sreekanth Reddy 2012-11-30 10212 /**
f92363d12359498f Sreekanth Reddy 2012-11-30 10213 * _scsih_scan_for_devices_after_reset - scan for devices after host reset
f92363d12359498f Sreekanth Reddy 2012-11-30 10214 * @ioc: per adapter object
f92363d12359498f Sreekanth Reddy 2012-11-30 10215 */
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;
16dc4b15325d1db7 Lee Jones 2021-02-25 10245
919d8a3f3fef9910 Joe Perches 2018-09-17 10246 ioc_info(ioc, "scan devices: start\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10247
f92363d12359498f Sreekanth Reddy 2012-11-30 10248 _scsih_sas_host_refresh(ioc);
f92363d12359498f Sreekanth Reddy 2012-11-30 10249
919d8a3f3fef9910 Joe Perches 2018-09-17 10250 ioc_info(ioc, "\tscan devices: expanders start\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10251
f92363d12359498f Sreekanth Reddy 2012-11-30 10252 /* expanders */
f92363d12359498f Sreekanth Reddy 2012-11-30 10253 handle = 0xFFFF;
f92363d12359498f Sreekanth Reddy 2012-11-30 10254 while (!(mpt3sas_config_get_expander_pg0(ioc, &mpi_reply, &expander_pg0,
f92363d12359498f Sreekanth Reddy 2012-11-30 10255 MPI2_SAS_EXPAND_PGAD_FORM_GET_NEXT_HNDL, handle))) {
f92363d12359498f Sreekanth Reddy 2012-11-30 10256 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
f92363d12359498f Sreekanth Reddy 2012-11-30 10257 MPI2_IOCSTATUS_MASK;
f92363d12359498f Sreekanth Reddy 2012-11-30 10258 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10259 ioc_info(ioc, "\tbreak from expander scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10260 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
f92363d12359498f Sreekanth Reddy 2012-11-30 10261 break;
f92363d12359498f Sreekanth Reddy 2012-11-30 10262 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10263 handle = le16_to_cpu(expander_pg0.DevHandle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10264 spin_lock_irqsave(&ioc->sas_node_lock, flags);
7d310f241001e090 Sreekanth Reddy 2020-10-27 10265 port_id = expander_pg0.PhysicalPort;
f92363d12359498f Sreekanth Reddy 2012-11-30 10266 expander_device = mpt3sas_scsih_expander_find_by_sas_address(
7d310f241001e090 Sreekanth Reddy 2020-10-27 10267 ioc, le64_to_cpu(expander_pg0.SASAddress),
34b0a78532f61e60 Sreekanth Reddy 2020-10-27 10268 mpt3sas_get_port_by_id(ioc, port_id, 0));
f92363d12359498f Sreekanth Reddy 2012-11-30 10269 spin_unlock_irqrestore(&ioc->sas_node_lock, flags);
f92363d12359498f Sreekanth Reddy 2012-11-30 10270 if (expander_device)
f92363d12359498f Sreekanth Reddy 2012-11-30 10271 _scsih_refresh_expander_links(ioc, expander_device,
f92363d12359498f Sreekanth Reddy 2012-11-30 10272 handle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10273 else {
919d8a3f3fef9910 Joe Perches 2018-09-17 10274 ioc_info(ioc, "\tBEFORE adding expander: handle (0x%04x), sas_addr(0x%016llx)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10275 handle,
919d8a3f3fef9910 Joe Perches 2018-09-17 10276 (u64)le64_to_cpu(expander_pg0.SASAddress));
f92363d12359498f Sreekanth Reddy 2012-11-30 10277 _scsih_expander_add(ioc, handle);
919d8a3f3fef9910 Joe Perches 2018-09-17 10278 ioc_info(ioc, "\tAFTER adding expander: handle (0x%04x), sas_addr(0x%016llx)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10279 handle,
919d8a3f3fef9910 Joe Perches 2018-09-17 10280 (u64)le64_to_cpu(expander_pg0.SASAddress));
f92363d12359498f Sreekanth Reddy 2012-11-30 10281 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10282 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10283
919d8a3f3fef9910 Joe Perches 2018-09-17 10284 ioc_info(ioc, "\tscan devices: expanders complete\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10285
f92363d12359498f Sreekanth Reddy 2012-11-30 10286 if (!ioc->ir_firmware)
f92363d12359498f Sreekanth Reddy 2012-11-30 10287 goto skip_to_sas;
f92363d12359498f Sreekanth Reddy 2012-11-30 10288
919d8a3f3fef9910 Joe Perches 2018-09-17 10289 ioc_info(ioc, "\tscan devices: phys disk start\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10290
f92363d12359498f Sreekanth Reddy 2012-11-30 10291 /* phys disk */
f92363d12359498f Sreekanth Reddy 2012-11-30 10292 phys_disk_num = 0xFF;
f92363d12359498f Sreekanth Reddy 2012-11-30 10293 while (!(mpt3sas_config_get_phys_disk_pg0(ioc, &mpi_reply,
f92363d12359498f Sreekanth Reddy 2012-11-30 10294 &pd_pg0, MPI2_PHYSDISK_PGAD_FORM_GET_NEXT_PHYSDISKNUM,
f92363d12359498f Sreekanth Reddy 2012-11-30 10295 phys_disk_num))) {
f92363d12359498f Sreekanth Reddy 2012-11-30 10296 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
f92363d12359498f Sreekanth Reddy 2012-11-30 10297 MPI2_IOCSTATUS_MASK;
f92363d12359498f Sreekanth Reddy 2012-11-30 10298 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10299 ioc_info(ioc, "\tbreak from phys disk scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10300 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
f92363d12359498f Sreekanth Reddy 2012-11-30 10301 break;
f92363d12359498f Sreekanth Reddy 2012-11-30 10302 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10303 phys_disk_num = pd_pg0.PhysDiskNum;
f92363d12359498f Sreekanth Reddy 2012-11-30 10304 handle = le16_to_cpu(pd_pg0.DevHandle);
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10305 sas_device = mpt3sas_get_sdev_by_handle(ioc, handle);
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10306 if (sas_device) {
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10307 sas_device_put(sas_device);
f92363d12359498f Sreekanth Reddy 2012-11-30 10308 continue;
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10309 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10310 if (mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply,
f92363d12359498f Sreekanth Reddy 2012-11-30 10311 &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
f92363d12359498f Sreekanth Reddy 2012-11-30 10312 handle) != 0)
f92363d12359498f Sreekanth Reddy 2012-11-30 10313 continue;
f92363d12359498f Sreekanth Reddy 2012-11-30 10314 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
f92363d12359498f Sreekanth Reddy 2012-11-30 10315 MPI2_IOCSTATUS_MASK;
f92363d12359498f Sreekanth Reddy 2012-11-30 10316 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10317 ioc_info(ioc, "\tbreak from phys disk scan ioc_status(0x%04x), loginfo(0x%08x)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10318 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
f92363d12359498f Sreekanth Reddy 2012-11-30 10319 break;
f92363d12359498f Sreekanth Reddy 2012-11-30 10320 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10321 parent_handle = le16_to_cpu(sas_device_pg0.ParentDevHandle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10322 if (!_scsih_get_sas_address(ioc, parent_handle,
f92363d12359498f Sreekanth Reddy 2012-11-30 10323 &sas_address)) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10324 ioc_info(ioc, "\tBEFORE adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10325 handle,
919d8a3f3fef9910 Joe Perches 2018-09-17 10326 (u64)le64_to_cpu(sas_device_pg0.SASAddress));
e2f0cdf7525353d8 Sreekanth Reddy 2020-10-27 10327 port_id = sas_device_pg0.PhysicalPort;
f92363d12359498f Sreekanth Reddy 2012-11-30 10328 mpt3sas_transport_update_links(ioc, sas_address,
f92363d12359498f Sreekanth Reddy 2012-11-30 10329 handle, sas_device_pg0.PhyNum,
e2f0cdf7525353d8 Sreekanth Reddy 2020-10-27 10330 MPI2_SAS_NEG_LINK_RATE_1_5,
34b0a78532f61e60 Sreekanth Reddy 2020-10-27 10331 mpt3sas_get_port_by_id(ioc, port_id, 0));
f92363d12359498f Sreekanth Reddy 2012-11-30 10332 set_bit(handle, ioc->pd_handles);
f92363d12359498f Sreekanth Reddy 2012-11-30 10333 retry_count = 0;
f92363d12359498f Sreekanth Reddy 2012-11-30 10334 /* This will retry adding the end device.
f92363d12359498f Sreekanth Reddy 2012-11-30 10335 * _scsih_add_device() will decide on retries and
f92363d12359498f Sreekanth Reddy 2012-11-30 10336 * return "1" when it should be retried
f92363d12359498f Sreekanth Reddy 2012-11-30 10337 */
f92363d12359498f Sreekanth Reddy 2012-11-30 10338 while (_scsih_add_device(ioc, handle, retry_count++,
f92363d12359498f Sreekanth Reddy 2012-11-30 10339 1)) {
f92363d12359498f Sreekanth Reddy 2012-11-30 10340 ssleep(1);
f92363d12359498f Sreekanth Reddy 2012-11-30 10341 }
919d8a3f3fef9910 Joe Perches 2018-09-17 10342 ioc_info(ioc, "\tAFTER adding phys disk: handle (0x%04x), sas_addr(0x%016llx)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10343 handle,
919d8a3f3fef9910 Joe Perches 2018-09-17 10344 (u64)le64_to_cpu(sas_device_pg0.SASAddress));
f92363d12359498f Sreekanth Reddy 2012-11-30 10345 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10346 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10347
919d8a3f3fef9910 Joe Perches 2018-09-17 10348 ioc_info(ioc, "\tscan devices: phys disk complete\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10349
919d8a3f3fef9910 Joe Perches 2018-09-17 10350 ioc_info(ioc, "\tscan devices: volumes start\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10351
f92363d12359498f Sreekanth Reddy 2012-11-30 10352 /* volumes */
f92363d12359498f Sreekanth Reddy 2012-11-30 10353 handle = 0xFFFF;
f92363d12359498f Sreekanth Reddy 2012-11-30 10354 while (!(mpt3sas_config_get_raid_volume_pg1(ioc, &mpi_reply,
a5ab8c19b6f70474 Lee Jones 2021-02-26 10355 volume_pg1, MPI2_RAID_VOLUME_PGAD_FORM_GET_NEXT_HANDLE, handle))) {
f92363d12359498f Sreekanth Reddy 2012-11-30 10356 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
f92363d12359498f Sreekanth Reddy 2012-11-30 10357 MPI2_IOCSTATUS_MASK;
f92363d12359498f Sreekanth Reddy 2012-11-30 10358 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10359 ioc_info(ioc, "\tbreak from volume scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10360 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
f92363d12359498f Sreekanth Reddy 2012-11-30 10361 break;
f92363d12359498f Sreekanth Reddy 2012-11-30 10362 }
b04209dac6aabeb1 Lee Jones 2021-02-26 10363 handle = le16_to_cpu(volume_pg1->DevHandle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10364 spin_lock_irqsave(&ioc->raid_device_lock, flags);
f92363d12359498f Sreekanth Reddy 2012-11-30 10365 raid_device = _scsih_raid_device_find_by_wwid(ioc,
b04209dac6aabeb1 Lee Jones 2021-02-26 10366 le64_to_cpu(volume_pg1->WWID));
f92363d12359498f Sreekanth Reddy 2012-11-30 10367 spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
f92363d12359498f Sreekanth Reddy 2012-11-30 10368 if (raid_device)
f92363d12359498f Sreekanth Reddy 2012-11-30 10369 continue;
f92363d12359498f Sreekanth Reddy 2012-11-30 10370 if (mpt3sas_config_get_raid_volume_pg0(ioc, &mpi_reply,
a5ab8c19b6f70474 Lee Jones 2021-02-26 10371 volume_pg0, MPI2_RAID_VOLUME_PGAD_FORM_HANDLE, handle,
f92363d12359498f Sreekanth Reddy 2012-11-30 10372 sizeof(Mpi2RaidVolPage0_t)))
f92363d12359498f Sreekanth Reddy 2012-11-30 10373 continue;
f92363d12359498f Sreekanth Reddy 2012-11-30 10374 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
f92363d12359498f Sreekanth Reddy 2012-11-30 10375 MPI2_IOCSTATUS_MASK;
f92363d12359498f Sreekanth Reddy 2012-11-30 10376 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10377 ioc_info(ioc, "\tbreak from volume scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10378 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
f92363d12359498f Sreekanth Reddy 2012-11-30 10379 break;
f92363d12359498f Sreekanth Reddy 2012-11-30 10380 }
b04209dac6aabeb1 Lee Jones 2021-02-26 10381 if (volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_OPTIMAL ||
b04209dac6aabeb1 Lee Jones 2021-02-26 10382 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_ONLINE ||
b04209dac6aabeb1 Lee Jones 2021-02-26 10383 volume_pg0->VolumeState == MPI2_RAID_VOL_STATE_DEGRADED) {
f92363d12359498f Sreekanth Reddy 2012-11-30 10384 memset(&element, 0, sizeof(Mpi2EventIrConfigElement_t));
f92363d12359498f Sreekanth Reddy 2012-11-30 10385 element.ReasonCode = MPI2_EVENT_IR_CHANGE_RC_ADDED;
b04209dac6aabeb1 Lee Jones 2021-02-26 10386 element.VolDevHandle = volume_pg1->DevHandle;
919d8a3f3fef9910 Joe Perches 2018-09-17 10387 ioc_info(ioc, "\tBEFORE adding volume: handle (0x%04x)\n",
b04209dac6aabeb1 Lee Jones 2021-02-26 10388 volume_pg1->DevHandle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10389 _scsih_sas_volume_add(ioc, &element);
919d8a3f3fef9910 Joe Perches 2018-09-17 10390 ioc_info(ioc, "\tAFTER adding volume: handle (0x%04x)\n",
b04209dac6aabeb1 Lee Jones 2021-02-26 10391 volume_pg1->DevHandle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10392 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10393 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10394
919d8a3f3fef9910 Joe Perches 2018-09-17 10395 ioc_info(ioc, "\tscan devices: volumes complete\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10396
f92363d12359498f Sreekanth Reddy 2012-11-30 10397 skip_to_sas:
f92363d12359498f Sreekanth Reddy 2012-11-30 10398
919d8a3f3fef9910 Joe Perches 2018-09-17 10399 ioc_info(ioc, "\tscan devices: end devices start\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10400
f92363d12359498f Sreekanth Reddy 2012-11-30 10401 /* sas devices */
f92363d12359498f Sreekanth Reddy 2012-11-30 10402 handle = 0xFFFF;
f92363d12359498f Sreekanth Reddy 2012-11-30 10403 while (!(mpt3sas_config_get_sas_device_pg0(ioc, &mpi_reply,
f92363d12359498f Sreekanth Reddy 2012-11-30 10404 &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_GET_NEXT_HANDLE,
f92363d12359498f Sreekanth Reddy 2012-11-30 10405 handle))) {
f92363d12359498f Sreekanth Reddy 2012-11-30 10406 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
f92363d12359498f Sreekanth Reddy 2012-11-30 10407 MPI2_IOCSTATUS_MASK;
f92363d12359498f Sreekanth Reddy 2012-11-30 10408 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10409 ioc_info(ioc, "\tbreak from end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10410 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
f92363d12359498f Sreekanth Reddy 2012-11-30 10411 break;
f92363d12359498f Sreekanth Reddy 2012-11-30 10412 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10413 handle = le16_to_cpu(sas_device_pg0.DevHandle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10414 if (!(_scsih_is_end_device(
f92363d12359498f Sreekanth Reddy 2012-11-30 10415 le32_to_cpu(sas_device_pg0.DeviceInfo))))
f92363d12359498f Sreekanth Reddy 2012-11-30 10416 continue;
e2f0cdf7525353d8 Sreekanth Reddy 2020-10-27 10417 port_id = sas_device_pg0.PhysicalPort;
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10418 sas_device = mpt3sas_get_sdev_by_addr(ioc,
7d310f241001e090 Sreekanth Reddy 2020-10-27 10419 le64_to_cpu(sas_device_pg0.SASAddress),
34b0a78532f61e60 Sreekanth Reddy 2020-10-27 10420 mpt3sas_get_port_by_id(ioc, port_id, 0));
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10421 if (sas_device) {
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10422 sas_device_put(sas_device);
f92363d12359498f Sreekanth Reddy 2012-11-30 10423 continue;
d1cb5e495e5384f6 Sreekanth Reddy 2015-11-11 10424 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10425 parent_handle = le16_to_cpu(sas_device_pg0.ParentDevHandle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10426 if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address)) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10427 ioc_info(ioc, "\tBEFORE adding end device: handle (0x%04x), sas_addr(0x%016llx)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10428 handle,
919d8a3f3fef9910 Joe Perches 2018-09-17 10429 (u64)le64_to_cpu(sas_device_pg0.SASAddress));
f92363d12359498f Sreekanth Reddy 2012-11-30 10430 mpt3sas_transport_update_links(ioc, sas_address, handle,
e2f0cdf7525353d8 Sreekanth Reddy 2020-10-27 10431 sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5,
34b0a78532f61e60 Sreekanth Reddy 2020-10-27 10432 mpt3sas_get_port_by_id(ioc, port_id, 0));
f92363d12359498f Sreekanth Reddy 2012-11-30 10433 retry_count = 0;
f92363d12359498f Sreekanth Reddy 2012-11-30 10434 /* This will retry adding the end device.
f92363d12359498f Sreekanth Reddy 2012-11-30 10435 * _scsih_add_device() will decide on retries and
f92363d12359498f Sreekanth Reddy 2012-11-30 10436 * return "1" when it should be retried
f92363d12359498f Sreekanth Reddy 2012-11-30 10437 */
f92363d12359498f Sreekanth Reddy 2012-11-30 10438 while (_scsih_add_device(ioc, handle, retry_count++,
f92363d12359498f Sreekanth Reddy 2012-11-30 10439 0)) {
f92363d12359498f Sreekanth Reddy 2012-11-30 10440 ssleep(1);
f92363d12359498f Sreekanth Reddy 2012-11-30 10441 }
919d8a3f3fef9910 Joe Perches 2018-09-17 10442 ioc_info(ioc, "\tAFTER adding end device: handle (0x%04x), sas_addr(0x%016llx)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10443 handle,
919d8a3f3fef9910 Joe Perches 2018-09-17 10444 (u64)le64_to_cpu(sas_device_pg0.SASAddress));
f92363d12359498f Sreekanth Reddy 2012-11-30 10445 }
f92363d12359498f Sreekanth Reddy 2012-11-30 10446 }
919d8a3f3fef9910 Joe Perches 2018-09-17 10447 ioc_info(ioc, "\tscan devices: end devices complete\n");
919d8a3f3fef9910 Joe Perches 2018-09-17 10448 ioc_info(ioc, "\tscan devices: pcie end devices start\n");
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10449
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10450 /* pcie devices */
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10451 handle = 0xFFFF;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10452 while (!(mpt3sas_config_get_pcie_device_pg0(ioc, &mpi_reply,
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10453 &pcie_device_pg0, MPI26_PCIE_DEVICE_PGAD_FORM_GET_NEXT_HANDLE,
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10454 handle))) {
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10455 ioc_status = le16_to_cpu(mpi_reply.IOCStatus)
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10456 & MPI2_IOCSTATUS_MASK;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10457 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
919d8a3f3fef9910 Joe Perches 2018-09-17 10458 ioc_info(ioc, "\tbreak from pcie end device scan: ioc_status(0x%04x), loginfo(0x%08x)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10459 ioc_status, le32_to_cpu(mpi_reply.IOCLogInfo));
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10460 break;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10461 }
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10462 handle = le16_to_cpu(pcie_device_pg0.DevHandle);
5bb309dbbbf21577 Suganath Prabu 2019-08-03 10463 if (!(_scsih_is_nvme_pciescsi_device(
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10464 le32_to_cpu(pcie_device_pg0.DeviceInfo))))
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10465 continue;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10466 pcie_device = mpt3sas_get_pdev_by_wwid(ioc,
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10467 le64_to_cpu(pcie_device_pg0.WWID));
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10468 if (pcie_device) {
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10469 pcie_device_put(pcie_device);
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10470 continue;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10471 }
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10472 retry_count = 0;
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10473 parent_handle = le16_to_cpu(pcie_device_pg0.ParentDevHandle);
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10474 _scsih_pcie_add_device(ioc, handle);
f92363d12359498f Sreekanth Reddy 2012-11-30 10475
919d8a3f3fef9910 Joe Perches 2018-09-17 10476 ioc_info(ioc, "\tAFTER adding pcie end device: handle (0x%04x), wwid(0x%016llx)\n",
919d8a3f3fef9910 Joe Perches 2018-09-17 10477 handle, (u64)le64_to_cpu(pcie_device_pg0.WWID));
ec051e5a4bbaa989 Suganath Prabu Subramani 2017-10-31 10478 }
16dc4b15325d1db7 Lee Jones 2021-02-25 10479
16dc4b15325d1db7 Lee Jones 2021-02-25 10480 kfree(volume_pg0);
16dc4b15325d1db7 Lee Jones 2021-02-25 10481 kfree(volume_pg1);
16dc4b15325d1db7 Lee Jones 2021-02-25 10482
919d8a3f3fef9910 Joe Perches 2018-09-17 10483 ioc_info(ioc, "\tpcie devices: pcie end devices complete\n");
919d8a3f3fef9910 Joe Perches 2018-09-17 10484 ioc_info(ioc, "scan devices: complete\n");
f92363d12359498f Sreekanth Reddy 2012-11-30 10485 }
c7a3570588826375 Bart Van Assche 2018-06-15 10486
:::::: The code at line 10244 was first introduced by commit
:::::: 16dc4b15325d1db79fccc9a2cdeab4ed1f61c3db scsi: mpt3sas: mpt3sas_scs: Move a little data from the stack onto the heap
:::::: TO: Lee Jones <lee.jones@linaro.org>
:::::: CC: Lee Jones <lee.jones@linaro.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38518 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [lee-linaro:tb-fix-w1-warnings 216/226] drivers/scsi/mpt3sas/mpt3sas_scsih.c:10244 _scsih_scan_for_devices_after_reset() warn: possible memory leak of 'volume_pg0'
@ 2021-02-27 15:01 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-02-27 15:01 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4009 bytes --]
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
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
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
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38518 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [lee-linaro:tb-fix-w1-warnings 216/226] drivers/scsi/mpt3sas/mpt3sas_scsih.c:10244 _scsih_scan_for_devices_after_reset() warn: possible memory leak of 'volume_pg0'
@ 2021-02-27 15:01 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-02-27 15:01 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 4009 bytes --]
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
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
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
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38518 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-27 15:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-27 1:26 [lee-linaro:tb-fix-w1-warnings 216/226] drivers/scsi/mpt3sas/mpt3sas_scsih.c:10244 _scsih_scan_for_devices_after_reset() warn: possible memory leak of 'volume_pg0' kernel test robot
2021-02-27 15:01 Dan Carpenter
2021-02-27 15:01 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.