Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3881851pxb; Tue, 17 Nov 2020 06:07:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSYpbczngEu99woEpRnsUppivpgqUyGoJHM2dW7xUzV6wc8t7jsnvxO/TGGNhvJTOKOeXT X-Received: by 2002:a17:907:1112:: with SMTP id qu18mr19788047ejb.507.1605622055727; Tue, 17 Nov 2020 06:07:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605622055; cv=none; d=google.com; s=arc-20160816; b=iz5c01wASNEksvl56MGXFSGKbTGZ+BwuogrdPclUFgepAu8vWpabhtRZJwmRS+Cui5 zWJgS3IoOcITA6oeM9kdy0PfvLvdqViGvP9p1kWVhVUj/xHK/VsiUtJOStEfoCKeWhPe VFowQfrIDIynCUf59LcP9uka9VJAyT3cbzDeKX5DqBXsPWa2Dd5yhkaFywwmDtQAEuF/ mgYr+LW/98L0MIeNHfrj9GrJwtH3pWgRQ2zxT1fFRpJCYyHKD0jng19vcFAbchVAZXZA 7AuovyQKW3CTgtz7g6zN3sqBZVD8Y7Oc+4ExRfjhCufzeXeTDKMGhO3qOPiyAghYxbyE uUXQ== 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=xXP7aTd7EcdzDSPUwCuqbdG+ngGix7pmtLBkrxWtfeY=; b=AltcqKSy1SatxW4yeaVK3bqzVUIq3XyUvBtbnEOUhI7scAYIlizX8BXTm0al3Q/UBr IZ7REHULVTbImlI79HYt0GemwI2taDw8O9+RV2bK53C3PUMtLu3e37I1qVdOE9lu6NO4 IrfCR7ZYMV+NnGftw92uFOM3+FsEMiaj5EBo+9Ali532EtGZE3c+rlVZMUdjpvU32d5S /c68pI5R2hhihuhLBr4Mbs/dDioByMFTt94ImI1l7cyju+SiE3IK3Ql5L9OusgiYqIYo GAYnXo3sTvqJUy+qEBuHLu7zkrd5JKQLxGd5PJqkh8QrrfqR/t3abv2rrOzUPPEFT5f+ TiMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Y8wZI/uK"; 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 b20si12535885ejb.424.2020.11.17.06.07.10; Tue, 17 Nov 2020 06:07:35 -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="Y8wZI/uK"; 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 S1731233AbgKQOCl (ORCPT + 99 others); Tue, 17 Nov 2020 09:02:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:44868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbgKQNOH (ORCPT ); Tue, 17 Nov 2020 08:14:07 -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 47FF42225B; Tue, 17 Nov 2020 13:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618847; bh=hfVjhpLdemkw7Vf4tF+lJ893noreThwlUGghtIhaEXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8wZI/uKs0jTPWAT7LaDHA3ujkToa8DHgayUT+zqRX99zwEmYYGuqSpUgC8nG3NmM K8W/SjBU0xJoV9zA/OFo1s+VpYwc1WcKJyeJniOewvysvLODrSMNcehJz1tyPUhSEs AJOzrWYBUXOQt10OhUzSxNu/RsVMeVnZGpj5FBE0= 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.14 27/85] scsi: hpsa: Fix memory leak in hpsa_init_one() Date: Tue, 17 Nov 2020 14:04:56 +0100 Message-Id: <20201117122112.368900483@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@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 3b892918d8219..9ad9910cc0855 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -8549,7 +8549,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; @@ -8564,6 +8564,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