mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] scsi: mvsas:fix memory leak
@ 2018-04-04  2:15 Xidong Wang
  2018-04-04 10:53 ` kbuild test robot
  2018-04-04 11:39 ` kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Xidong Wang @ 2018-04-04  2:15 UTC (permalink / raw)
  To: James E . J . Bottomley, Martin K . Petersen, Jack Wang,
	Johannes Thumshirn, Peter Senna Tschudin, Hannes Reinecke
  Cc: Kees Cook, Pan Bian, Xidong Wang, Romain Perier, linux-scsi,
	linux-kernel

In function mvs_pci_init(), the memory allocated by
scsi_host_alloc() is not released on the error path that mvi,
which holds the return value of mvs_pci_alloc(), is NULL.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang <wangxidong_97@163.com>
---
 drivers/scsi/mvsas/mv_init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 8c91637..bde4b50 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -371,6 +371,7 @@ static struct mvs_info *mvs_pci_alloc(struct pci_dev *pdev,
 		(1L << mvs_chips[ent->driver_data].slot_width) *
 		sizeof(struct mvs_slot_info), GFP_KERNEL);
 	if (!mvi)
+		scsi_host_put(shost);
 		return NULL;
 
 	mvi->pdev = pdev;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 1/1] scsi:mvsas:fix memory leak
@ 2018-04-04  2:37 Xidong Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Xidong Wang @ 2018-04-04  2:37 UTC (permalink / raw)
  To: James E . J . Bottomley, Martin K . Petersen, Jack Wang,
	Johannes Thumshirn, Hannes Reinecke
  Cc: Kees Cook, Pan Bian, Xidong Wang, Romain Perier, linux-scsi,
	linux-kernel

In function mvs_pci_init(), the memory allocated by
scsi_host_alloc() is not released on the error path that mvi,
which holds the return value of mvs_pci_alloc(), is NULL.
This will result in a memory leak bug.

Signed-off-by: Xidong Wang <wangxidong_97@163.com>
---
 drivers/scsi/mvsas/mv_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 8c91637..936b8ef 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -370,8 +370,10 @@ static struct mvs_info *mvs_pci_alloc(struct pci_dev *pdev,
 	mvi = kzalloc(sizeof(*mvi) +
 		(1L << mvs_chips[ent->driver_data].slot_width) *
 		sizeof(struct mvs_slot_info), GFP_KERNEL);
-	if (!mvi)
+	if (!mvi) {
+		scsi_host_put(shost);
 		return NULL;
+	}
 
 	mvi->pdev = pdev;
 	mvi->dev = &pdev->dev;
-- 
2.7.4

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

end of thread, other threads:[~2018-04-04 11:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04  2:15 [PATCH 1/1] scsi: mvsas:fix memory leak Xidong Wang
2018-04-04 10:53 ` kbuild test robot
2018-04-04 11:39 ` kbuild test robot
2018-04-04  2:37 [PATCH 1/1] scsi:mvsas:fix " Xidong Wang

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

all inboxes | Powered by JetHome®