diff mbox series

[v1] mpt3sas: Fix double free warnings

Message ID 20200508110738.30732-1-suganath-prabu.subramani@broadcom.com (mailing list archive)
State Mainlined
Commit cbbfdb2a2416c9f0cde913cf09670097ac281282
Headers show
Series [v1] mpt3sas: Fix double free warnings | expand

Commit Message

Suganath Prabu S May 8, 2020, 11:07 a.m. UTC
Fix below warnings from Smatch static analyser:

drivers/scsi/mpt3sas/mpt3sas_base.c:5256 _base_allocate_memory_pools()
warn: 'ioc->hpr_lookup' double freed

drivers/scsi/mpt3sas/mpt3sas_base.c:5256 _base_allocate_memory_pools()
warn: 'ioc->internal_lookup' double freed

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
---
v1 Change:
Removed checks before kfree().

 drivers/scsi/mpt3sas/mpt3sas_base.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Martin K. Petersen May 12, 2020, 3:28 a.m. UTC | #1
On Fri, 8 May 2020 07:07:38 -0400, Suganath Prabu S wrote:

> Fix below warnings from Smatch static analyser:
> 
> drivers/scsi/mpt3sas/mpt3sas_base.c:5256 _base_allocate_memory_pools()
> warn: 'ioc->hpr_lookup' double freed
> 
> drivers/scsi/mpt3sas/mpt3sas_base.c:5256 _base_allocate_memory_pools()
> warn: 'ioc->internal_lookup' double freed

Applied to 5.8/scsi-queue, thanks!

[1/1] scsi: mpt3sas: Fix double free warnings
      https://git.kernel.org/mkp/scsi/c/cbbfdb2a2416
diff mbox series

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 7fa3bdb..dc260fe 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -4899,7 +4899,9 @@  _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
 	}
 
 	kfree(ioc->hpr_lookup);
+	ioc->hpr_lookup = NULL;
 	kfree(ioc->internal_lookup);
+	ioc->internal_lookup = NULL;
 	if (ioc->chain_lookup) {
 		for (i = 0; i < ioc->scsiio_depth; i++) {
 			for (j = ioc->chains_per_prp_buffer;