Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1074913ybl; Wed, 14 Aug 2019 10:17:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrAHyD8wYav8P0RUy+ZU6iDJHW30/wdEFHxLwe0JKhbw6/E2tZ57PGBIFwymeP2GxCGwxz X-Received: by 2002:a17:90a:5288:: with SMTP id w8mr749386pjh.61.1565803034749; Wed, 14 Aug 2019 10:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803034; cv=none; d=google.com; s=arc-20160816; b=P67Otu3xLzGKlmYbAiwe9smAOdoNEOuAJfqm0YxLSUyO4ZP3Z/3z8ISlywuxRLOvu5 8oKgvvH2OmNi0369sb8jHvPDiIl4QNwGOP40fD3fBzdOlaibgS9fn1PQDlbJU2eZXz1F aS01CmocFvRkVSFbZboG4x4NLygp6vNbrbCdlp5l7IHd8+KNAeYb9cS+jdVS+SeooGpr +B33n1n9u3zWpA4dPF65O8r5KcFvsmjTrQD1LEyiV3i832hhkJ7Gr7DIjKzSMTxk8Ndc 3WH6UfMdP/nvN3ViICAwQK4RsnxBNADDLVhevjFM+RYsnUAqc7cSiBzsmOmndf0qHx0h cpkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4D8QD6OFnC3sRVnJ4p/WKsKDyAgKcJ6joJ9XcRnJD9Y=; b=M/TxC08GTO5Z8ptoHarKmBATorsdwLY+Dcm+kTMFSy6tSzyVodXaN0OlrBE5/xbie1 qaCXI+Jp4soJcTiHgjizri4nN1e++idPYNW4Zqr3fBo2HkcbbU19KDAA4FfibS7fucB2 peYZwuiJCiKwgNeL3atdod9wkkg4BJrWiTMIrHcnahX9nv6FAmRocBtaU3jlDDkTILAP QLX12fvB4pgW7wHZ5gMMrz41CQE3Oh9lu6IStuHvMBVmp1wmQnYi6uhbszWhjYfED9fM e1dm32wrpmRrqLbX1CNTeHt7EpPWEzimMSYmCL1ce1y3fB9PMjk4kV2z+caq0+j/R2kw mSMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=my7qgmR8; 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 16si65362pfc.213.2019.08.14.10.16.58; Wed, 14 Aug 2019 10:17:14 -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=@kernel.org header.s=default header.b=my7qgmR8; 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 S1731203AbfHNRPP (ORCPT + 99 others); Wed, 14 Aug 2019 13:15:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:39810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731194AbfHNRPN (ORCPT ); Wed, 14 Aug 2019 13:15:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 B8A442173B; Wed, 14 Aug 2019 17:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802913; bh=rEz9Q5kVtaIl+plmnxqQyi9B4XJzmRk64BEqAW4tO4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=my7qgmR8HAUGnnHVi9+w6kMs81dbk3TPpepIcHQVh781ohZUuNcgHhtB9hg+d4SOF P6Ynnwfmk3/rMkBjHrTY+3SHOyJTZI3pyKiYrB2GUZ3/IEHvhm+bG1fgemkZyCDZB+ QHaVOOvHPK1/DfgrEYK2jzm/pbSKNM6jZgr7NQWw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Sasha Levin Subject: [PATCH 4.14 48/69] test_firmware: fix a memory leak bug Date: Wed, 14 Aug 2019 19:01:46 +0200 Message-Id: <20190814165748.759432986@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d4fddac5a51c378c5d3e68658816c37132611e1f ] In test_firmware_init(), the buffer pointed to by the global pointer 'test_fw_config' is allocated through kzalloc(). Then, the buffer is initialized in __test_firmware_config_init(). In the case that the initialization fails, the following execution in test_firmware_init() needs to be terminated with an error code returned to indicate this failure. However, the allocated buffer is not freed on this execution path, leading to a memory leak bug. To fix the above issue, free the allocated buffer before returning from test_firmware_init(). Signed-off-by: Wenwen Wang Link: https://lore.kernel.org/r/1563084696-6865-1-git-send-email-wang6495@umn.edu Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- lib/test_firmware.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/test_firmware.c b/lib/test_firmware.c index f978aebe60c5b..2e5e18bbfd28e 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -895,8 +895,11 @@ static int __init test_firmware_init(void) return -ENOMEM; rc = __test_firmware_config_init(); - if (rc) + if (rc) { + kfree(test_fw_config); + pr_err("could not init firmware test config: %d\n", rc); return rc; + } rc = misc_register(&test_fw_misc_device); if (rc) { -- 2.20.1