Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3876762pxb; Tue, 17 Nov 2020 06:01:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzA3W/wSdDVn8xrwEJDVcIHH44LoA6jszMFHRQt+Iju/djQA7VglmAEiDsnpAhpv+VU8dVB X-Received: by 2002:aa7:c54c:: with SMTP id s12mr21507931edr.175.1605621713068; Tue, 17 Nov 2020 06:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621713; cv=none; d=google.com; s=arc-20160816; b=gr3waGePwgb9g9RApZLjjvWmd6Cn3U1Pbxdsh72iwdgv++NjjSS+JRUzAlt1Ufp6Th DnGP2swIf2s9zxquvItNd76nP0FqTunhnXvXyqK4vJPslRuVfdk2ZJhBUgBTp/TPmO82 VY3oIUTyxmy7CDJnl1yGyTDtbHXw32XVQFReWw5L8gjPnpYpA8ZBAzVGTpha74oQFeby xckAomZF2SYzTYqMf6H1B4i3JpZFnSBFsjyL+fkjc5l3mLGqtL3+LOdp5MID1oajuY7V 5Watqhze7DJgu7e0DTsqqm4mF+u9ZApQoLp/ueHQWpVnNrk/RlCZYmG1pRRxCLfT6FHw neOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kbzsXzcIM6hmvVMwin+gKo8Y6aNmu0paoFrnSY2axRw=; b=gcD3hN23AuUUJC4n8iK2vA7Xsne7ggvy0RHn3yjp7wPT6ISrTg2h8yNzbyOO4whVcW r1Nanx1OkGaOrqHchBDKf0d5RcjaXYTxwokv7wStmrmigZ3/M6KdoMdHWElz+JP2Zmmp ZORFbMwC9pw0GpDt3wmFvvV7QdBC7dfzmlY8BL/7Yy+CeduGLXPw1h25FgsXyna55Lmv 5xezOkOI00yTa29c67+IK3cy+GEpzeEKfCd/aW8ix8ItTH5CSyI7CFsjTwoN555UjA6g NKbkkRsWGiOaKzikkEYYgDwker0BrVVCumvi+7IamkLKbIHqwgBxIvSsfgSNjz0zCoDH JKEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zE6HpGJ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si15439376edf.2.2020.11.17.06.01.28; Tue, 17 Nov 2020 06:01:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zE6HpGJ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732792AbgKQN62 (ORCPT + 99 others); Tue, 17 Nov 2020 08:58:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:51378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730713AbgKQNSp (ORCPT ); Tue, 17 Nov 2020 08:18:45 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E3AA21734; Tue, 17 Nov 2020 13:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619123; bh=6rVD4hiILMeSQwU/qNvzGsziVmPVMtH4ZaaJwgLelLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zE6HpGJ3bNHNcaJ+HW+NzlXAY6yxAUyBY6uUKGfHtzqEOOcFeqnU/7Mq5LGggNjGm CSqBwcfSbPhxRbTx/+eU5NnI4A+lSa6v8YZdpddNNz1YfMWSD99pZlziQ21xCWQGbd Mgdww/pWxAHKWg37oVYPlOQiJli+qzqESGq6ZYF8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Don Brace , Keita Suzuki , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 035/101] scsi: hpsa: Fix memory leak in hpsa_init_one() Date: Tue, 17 Nov 2020 14:05:02 +0100 Message-Id: <20201117122114.798869957@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keita Suzuki [ Upstream commit af61bc1e33d2c0ec22612b46050f5b58ac56a962 ] When hpsa_scsi_add_host() fails, h->lastlogicals is leaked since it is missing a free() in the error handler. Fix this by adding free() when hpsa_scsi_add_host() fails. Link: https://lore.kernel.org/r/20201027073125.14229-1-keitasuzuki.park@sslab.ics.keio.ac.jp Tested-by: Don Brace Acked-by: Don Brace Signed-off-by: Keita Suzuki Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hpsa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 11de2198bb87d..0fe21cbdf0ca7 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -8781,7 +8781,7 @@ reinit_after_soft_reset: /* hook into SCSI subsystem */ rc = hpsa_scsi_add_host(h); if (rc) - goto clean7; /* perf, sg, cmd, irq, shost, pci, lu, aer/h */ + goto clean8; /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */ /* Monitor the controller for firmware lockups */ h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL; @@ -8796,6 +8796,8 @@ reinit_after_soft_reset: HPSA_EVENT_MONITOR_INTERVAL); return 0; +clean8: /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */ + kfree(h->lastlogicals); clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */ hpsa_free_performant_mode(h); h->access.set_intr_mask(h, HPSA_INTR_OFF); -- 2.27.0