public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mpt3sas: Fix double free warnings
@ 2020-05-08  9:18 Suganath Prabu S
  2020-05-08 10:42 ` Johannes Thumshirn
  2020-05-08 11:36 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Suganath Prabu S @ 2020-05-08  9:18 UTC (permalink / raw)
  To: linux-scsi
  Cc: dan.carpenter, Sathya.Prakash, sreekanth.reddy, Suganath Prabu S

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 <suganath-prabu.subramani@broadcom.com>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 7fa3bdb..a6dbc73 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -4898,8 +4898,14 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc)
 		    ioc->config_page, ioc->config_page_dma);
 	}
 
-	kfree(ioc->hpr_lookup);
-	kfree(ioc->internal_lookup);
+	if (ioc->hpr_lookup) {
+		kfree(ioc->hpr_lookup);
+		ioc->hpr_lookup = NULL;
+	}
+	if (ioc->internal_lookup) {
+		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;
-- 
2.18.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-08 11:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-08  9:18 [PATCH] mpt3sas: Fix double free warnings Suganath Prabu S
2020-05-08 10:42 ` Johannes Thumshirn
2020-05-08 11:36 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox