Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1083013ybl; Wed, 14 Aug 2019 10:25:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyeYFcKBes4NKwYLqtbPPjByQVQYwWeBMdz8UhCEZhjSMHF7lSN+4u0U9XRf1LiaQGFTIc X-Received: by 2002:a63:f857:: with SMTP id v23mr256556pgj.228.1565803509610; Wed, 14 Aug 2019 10:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803509; cv=none; d=google.com; s=arc-20160816; b=wDia1lX0YiHU6WiGU73+uw49RTa6FjfSIjH2XuQWBMbQXhPpbDGzoeWTiyv9gnxasj uBUcgchHMwKg5bgLJxhQ/qpIWLcBXhfwBqSOqTHAes/jQ+tD11ttL5E32fz0r/p8RQiM aiBO9DlyLjBYEPvDImZhWTVByT7CEIF6+xC3W6FcQB3oVYWdaautwPX8megxj02tZ9UH gzDE9o8U/Yy9i9ARJZGYHQsqoyY6u0053OYKe1njSVc0uympiYi4gRj6j1BYcQBVYCcg lRzSg2PFotDIJv6ScmCpaLyoIvV5FOVbcmkMytD+vLuyqYQC7mwG/F8d/NT/BFGrAUbA +4bQ== 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=Luj6wMDlD/gbk2oGV8uEgCB+uXXiO0QMMReYT75KEBc=; b=P1AkDjej68ZlSjYURBaax0OhP0jR2pEul0wpwN01oPgnAOanYOd69v5QJryhIOAybV 3Gym/9Oq708O+cp+KKmBcyuRhGBCVPdjIuN+vFu3bQh75RA8Q65ldz2j/Jhg8Pq6VPPG WOe9x836LGD+Vj0I0f/Imw7w4/uOW+z4awH+CtZW5lsJMrtmMg+UlGjYA5P80YENnZr8 jV79weq6ebgvejZaYc25nLB0vEqW1CuYhGIgWrTkkJZw2BVInkpgczGSTJOOaUHv2F4W s/B11Mk46Kanq4jnX6RD//lequZcWwfYOIZWCAvRn9Apmcx48DLA3R490BN3LW3/T1vN lujw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XDeGtsTn; 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 w8si103505pfn.190.2019.08.14.10.24.54; Wed, 14 Aug 2019 10:25:09 -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=XDeGtsTn; 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 S1728394AbfHNRYV (ORCPT + 99 others); Wed, 14 Aug 2019 13:24:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:55876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729701AbfHNRGj (ORCPT ); Wed, 14 Aug 2019 13:06:39 -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 67A4D2084D; Wed, 14 Aug 2019 17:06:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802398; bh=o1HknKAktox50Lr8eByWnXdw3nOw0WtDlgNr12VKcBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XDeGtsTnxRbSJuAHgBfYodnSKJ4e30j1aobUhQU9iySx/mS6VxDZWQEYYJ7MbBeMN wWkB+RqKmGa2Q+e/9rfKAnSs/lFiNqs4VgHwUfRZoA1k5lg1KJ+OicJhocJnTOK+mg crUnw0G5NVq3/riIqlQVaOXlqC2/Xp75okKdJkgA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Sasha Levin Subject: [PATCH 5.2 110/144] test_firmware: fix a memory leak bug Date: Wed, 14 Aug 2019 19:01:06 +0200 Message-Id: <20190814165804.513117773@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 83ea6c4e623cf..6ca97a63b3d6b 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -886,8 +886,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