drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
In scsih_pci_slot_reset(), if mpt3sas_base_hard_reset_handler()
fails, call mpt3sas_base_unmap_resources() to release the memory
allocated by mpt3sas_base_map_resources().
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 7092d0debef3..7a884a278163 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -12529,8 +12529,9 @@ scsih_pci_slot_reset(struct pci_dev *pdev)
if (!rc)
return PCI_ERS_RESULT_RECOVERED;
- else
- return PCI_ERS_RESULT_DISCONNECT;
+
+ mpt3sas_base_unmap_resources(ioc);
+ return PCI_ERS_RESULT_DISCONNECT;
}
/**
--
2.25.1
Hi Haoxiang,
kernel test robot noticed the following build errors:
[auto build test ERROR on jejb-scsi/for-next]
[also build test ERROR on mkp-scsi/for-next linus/master v6.19-rc7 next-20260123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/scsi-mpt3sas-fix-a-potential-memory-leak-in-scsih_pci_slot_reset/20260126-001420
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/r/20260125161201.2156109-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [PATCH] scsi: mpt3sas: fix a potential memory leak in scsih_pci_slot_reset()
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20260126/202601261539.Dt3EKe8y-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260126/202601261539.Dt3EKe8y-lkp@intel.com/reproduce)
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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601261539.Dt3EKe8y-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/scsi/mpt3sas/mpt3sas_scsih.c:12533:2: error: call to undeclared function 'mpt3sas_base_unmap_resources'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
12533 | mpt3sas_base_unmap_resources(ioc);
| ^
drivers/scsi/mpt3sas/mpt3sas_scsih.c:12533:2: note: did you mean 'mpt3sas_base_map_resources'?
drivers/scsi/mpt3sas/mpt3sas_base.h:1700:5: note: 'mpt3sas_base_map_resources' declared here
1700 | int mpt3sas_base_map_resources(struct MPT3SAS_ADAPTER *ioc);
| ^
1 error generated.
vim +/mpt3sas_base_unmap_resources +12533 drivers/scsi/mpt3sas/mpt3sas_scsih.c
12496
12497 /**
12498 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12499 * @pdev: PCI device struct
12500 *
12501 * Description: This routine is called by the pci error recovery
12502 * code after the PCI slot has been reset, just before we
12503 * should resume normal operations.
12504 */
12505 static pci_ers_result_t
12506 scsih_pci_slot_reset(struct pci_dev *pdev)
12507 {
12508 struct Scsi_Host *shost;
12509 struct MPT3SAS_ADAPTER *ioc;
12510 int rc;
12511
12512 if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
12513 return PCI_ERS_RESULT_DISCONNECT;
12514
12515 ioc_info(ioc, "PCI error: slot reset callback!!\n");
12516
12517 ioc->pci_error_recovery = 0;
12518 ioc->pdev = pdev;
12519 pci_restore_state(pdev);
12520 rc = mpt3sas_base_map_resources(ioc);
12521 if (rc)
12522 return PCI_ERS_RESULT_DISCONNECT;
12523
12524 ioc_info(ioc, "Issuing Hard Reset as part of PCI Slot Reset\n");
12525 rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
12526
12527 ioc_warn(ioc, "hard reset: %s\n",
12528 (rc == 0) ? "success" : "failed");
12529
12530 if (!rc)
12531 return PCI_ERS_RESULT_RECOVERED;
12532
12533 mpt3sas_base_unmap_resources(ioc);
12534 return PCI_ERS_RESULT_DISCONNECT;
12535 }
12536
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Haoxiang,
kernel test robot noticed the following build errors:
[auto build test ERROR on jejb-scsi/for-next]
[also build test ERROR on mkp-scsi/for-next linus/master v6.19-rc7 next-20260123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/scsi-mpt3sas-fix-a-potential-memory-leak-in-scsih_pci_slot_reset/20260126-001420
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/r/20260125161201.2156109-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [PATCH] scsi: mpt3sas: fix a potential memory leak in scsih_pci_slot_reset()
config: x86_64-rhel-9.4-ltp (https://download.01.org/0day-ci/archive/20260126/202601260641.AHnz8FCz-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260126/202601260641.AHnz8FCz-lkp@intel.com/reproduce)
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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601260641.AHnz8FCz-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/scsi/mpt3sas/mpt3sas_scsih.c: In function 'scsih_pci_slot_reset':
>> drivers/scsi/mpt3sas/mpt3sas_scsih.c:12533:9: error: implicit declaration of function 'mpt3sas_base_unmap_resources'; did you mean 'mpt3sas_base_map_resources'? [-Wimplicit-function-declaration]
12533 | mpt3sas_base_unmap_resources(ioc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| mpt3sas_base_map_resources
vim +12533 drivers/scsi/mpt3sas/mpt3sas_scsih.c
12496
12497 /**
12498 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12499 * @pdev: PCI device struct
12500 *
12501 * Description: This routine is called by the pci error recovery
12502 * code after the PCI slot has been reset, just before we
12503 * should resume normal operations.
12504 */
12505 static pci_ers_result_t
12506 scsih_pci_slot_reset(struct pci_dev *pdev)
12507 {
12508 struct Scsi_Host *shost;
12509 struct MPT3SAS_ADAPTER *ioc;
12510 int rc;
12511
12512 if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
12513 return PCI_ERS_RESULT_DISCONNECT;
12514
12515 ioc_info(ioc, "PCI error: slot reset callback!!\n");
12516
12517 ioc->pci_error_recovery = 0;
12518 ioc->pdev = pdev;
12519 pci_restore_state(pdev);
12520 rc = mpt3sas_base_map_resources(ioc);
12521 if (rc)
12522 return PCI_ERS_RESULT_DISCONNECT;
12523
12524 ioc_info(ioc, "Issuing Hard Reset as part of PCI Slot Reset\n");
12525 rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
12526
12527 ioc_warn(ioc, "hard reset: %s\n",
12528 (rc == 0) ? "success" : "failed");
12529
12530 if (!rc)
12531 return PCI_ERS_RESULT_RECOVERED;
12532
12533 mpt3sas_base_unmap_resources(ioc);
12534 return PCI_ERS_RESULT_DISCONNECT;
12535 }
12536
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Haoxiang,
kernel test robot noticed the following build errors:
[auto build test ERROR on jejb-scsi/for-next]
[also build test ERROR on mkp-scsi/for-next linus/master v6.19-rc7 next-20260123]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Haoxiang-Li/scsi-mpt3sas-fix-a-potential-memory-leak-in-scsih_pci_slot_reset/20260126-001420
base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/r/20260125161201.2156109-1-lihaoxiang%40isrc.iscas.ac.cn
patch subject: [PATCH] scsi: mpt3sas: fix a potential memory leak in scsih_pci_slot_reset()
config: arm-randconfig-002-20260126 (https://download.01.org/0day-ci/archive/20260126/202601261249.g2g6MMxT-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260126/202601261249.g2g6MMxT-lkp@intel.com/reproduce)
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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601261249.g2g6MMxT-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/scsi/mpt3sas/mpt3sas_scsih.c: In function 'scsih_pci_slot_reset':
>> drivers/scsi/mpt3sas/mpt3sas_scsih.c:12533:9: error: implicit declaration of function 'mpt3sas_base_unmap_resources'; did you mean 'mpt3sas_base_map_resources'? [-Werror=implicit-function-declaration]
12533 | mpt3sas_base_unmap_resources(ioc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| mpt3sas_base_map_resources
cc1: some warnings being treated as errors
vim +12533 drivers/scsi/mpt3sas/mpt3sas_scsih.c
12496
12497 /**
12498 * scsih_pci_slot_reset - Called when PCI slot has been reset.
12499 * @pdev: PCI device struct
12500 *
12501 * Description: This routine is called by the pci error recovery
12502 * code after the PCI slot has been reset, just before we
12503 * should resume normal operations.
12504 */
12505 static pci_ers_result_t
12506 scsih_pci_slot_reset(struct pci_dev *pdev)
12507 {
12508 struct Scsi_Host *shost;
12509 struct MPT3SAS_ADAPTER *ioc;
12510 int rc;
12511
12512 if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
12513 return PCI_ERS_RESULT_DISCONNECT;
12514
12515 ioc_info(ioc, "PCI error: slot reset callback!!\n");
12516
12517 ioc->pci_error_recovery = 0;
12518 ioc->pdev = pdev;
12519 pci_restore_state(pdev);
12520 rc = mpt3sas_base_map_resources(ioc);
12521 if (rc)
12522 return PCI_ERS_RESULT_DISCONNECT;
12523
12524 ioc_info(ioc, "Issuing Hard Reset as part of PCI Slot Reset\n");
12525 rc = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
12526
12527 ioc_warn(ioc, "hard reset: %s\n",
12528 (rc == 0) ? "success" : "failed");
12529
12530 if (!rc)
12531 return PCI_ERS_RESULT_RECOVERED;
12532
12533 mpt3sas_base_unmap_resources(ioc);
12534 return PCI_ERS_RESULT_DISCONNECT;
12535 }
12536
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.