Received: by 10.213.65.68 with SMTP id h4csp233868imn; Tue, 3 Apr 2018 19:39:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx49m/30UfrxHWEIgvbL/Hb8klmGAu8H+tJnC5K3p/IOZ9sES6yANwd0YMGrpUYCC9VmSwrsQ X-Received: by 2002:a17:902:2468:: with SMTP id m37-v6mr16325911plg.388.1522809588787; Tue, 03 Apr 2018 19:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522809588; cv=none; d=google.com; s=arc-20160816; b=0oHXJYE5Stoh6v4lEUJ9piv6k4nBucU43doIAv+oXeWe3IQHI3d3MPRN02OjthvjBO SCYsUVKLyCOIwaAkbB2BiMb/nQ68JyXqi8n5X+EdWnV258NtRGdGhqsu7wStL1phfdQd fVISkgTADXVSSVfukZQd8IOOTF5rBACpSxVm62WNtdpH8s843x2O5esL3rxsQCQRg2vb sEERKB+XUMlAHGMRV2u67Wd+Lq2GAgHr36la8HuGf2onmRICBGeIGagzYja6EM4xXiq7 IKVn0WBZI5RdnP0OlYUl8clrdFpfmzfSSrqbN2ERO4fnEBfLMiS7kZGn42BT2hf2DpFc 0CmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=UTweivWNrkuNFaaJxjZdiJMKWooOD9DjJsQslK9Sm8I=; b=TnuycLT8L0p0UNigkYNjOd7eDlox6356GrqRIVtQQpBATbFiQ74ealYUymB4NyQzPD RKMgwyOwXJj61Lv7yRlvnB68W0lPsxZVL7SJeElfYPDJOb+0lx02bQ+xVpOB4yDtKOLJ fJ4ubKOMUI/RScJP88TIdPJaRRPNEZ/N+vFd+ZhVwhwI+n3nm+oEt6wsY4/c2S0Nk+pP NaSS+eiefzRPiddJ+Ftu5gADMdm1XH6SWd/iAt6BYFIeCIHAGkeAKoLveSAjqvnO7bhE rzOBxAza00rER0roQMQ6Aw5Oq53PWfoN06Ddz0Vf+TUUfigpnkHua86bE7mJVXXyFb9u ErSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=Ehenik/J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9-v6si2018642pln.45.2018.04.03.19.39.34; Tue, 03 Apr 2018 19:39:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=Ehenik/J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755064AbeDDCiZ (ORCPT + 99 others); Tue, 3 Apr 2018 22:38:25 -0400 Received: from m12-18.163.com ([220.181.12.18]:49633 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754682AbeDDCiX (ORCPT ); Tue, 3 Apr 2018 22:38:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=UTweivWNrkuNFaaJxj ZdiJMKWooOD9DjJsQslK9Sm8I=; b=Ehenik/J+HTfJSql9Y6BbRB4rEcmR9uWjL JPMr0s5GObDY5XJ6edvNgNVPcCSXxd3AQi3kf60qBc44ncfxf6FeNtvpEDBUgkmN P5MaL8BLYMFEAp2J/p4lGKFxa6I09z12KA7eWZDHt/pGyW0B3R3MFh4wZzx8K7fv e63TisqcY= Received: from localhost.localdomain (unknown [106.120.213.14]) by smtp14 (Coremail) with SMTP id EsCowACHLkeCOsRatf3rDA--.42347S3; Wed, 04 Apr 2018 10:38:00 +0800 (CST) From: Xidong Wang 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@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] scsi:mvsas:fix memory leak Date: Wed, 4 Apr 2018 10:37:52 +0800 Message-Id: <1522809472-11749-1-git-send-email-wangxidong_97@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: EsCowACHLkeCOsRatf3rDA--.42347S3 X-Coremail-Antispam: 1Uf129KBjvdXoWruF1ktF4DXryDAw4kAw1kXwb_yoWfArb_WF W0qrn7Jr4Ykwn7Jw18WrsFvryI9w4fWa1kuFsIqryayF1fZF4DAa18WrnxZw4xC3y8CFyU A34DJw4fArnFvjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5aksDUUUUU== X-Originating-IP: [106.120.213.14] X-CM-SenderInfo: pzdqw5xlgr0wrbzxqiywtou0bp/1tbiyAge81p62HJpWAAAsW Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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