mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xidong Wang <wangxidong_97@163.com>
To: "James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Jack Wang <jinpu.wang@profitbricks.com>,
	Johannes Thumshirn <jthumshirn@suse.de>,
	Peter Senna Tschudin <peter.senna@collabora.com>,
	Hannes Reinecke <hare@suse.de>
Cc: Kees Cook <keescook@chromium.org>, Pan Bian <bianpan2016@163.com>,
	Xidong Wang <wangxidong_97@163.com>,
	Romain Perier <romain.perier@collabora.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] scsi: mvsas:fix memory leak
Date: Wed,  4 Apr 2018 10:15:20 +0800	[thread overview]
Message-ID: <1522808120-11432-1-git-send-email-wangxidong_97@163.com> (raw)

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

             reply	other threads:[~2018-04-04  2:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-04  2:15 Xidong Wang [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1522808120-11432-1-git-send-email-wangxidong_97@163.com \
    --to=wangxidong_97@163.com \
    --cc=bianpan2016@163.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jinpu.wang@profitbricks.com \
    --cc=jthumshirn@suse.de \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=peter.senna@collabora.com \
    --cc=romain.perier@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®