Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1078803ybl; Wed, 14 Aug 2019 10:20:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+SuQsyPmX5ZQ5WRkw/zxAiC4K2Yur2JSx+lqeyxpgeiFfvCJr2pidCm0I0/8ObqrjQNw2 X-Received: by 2002:a62:5c01:: with SMTP id q1mr1039942pfb.53.1565803255628; Wed, 14 Aug 2019 10:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803255; cv=none; d=google.com; s=arc-20160816; b=dhdbnEQYVRIrsRLtxsX9Q66J0Lx2ErxBAhpd/dIj3E1XpR1O+lhcaKqNgObb0l8kMz qWLHTRYjtbZ/m2w3eco6rhQ/2Oc1viWGbSnEv3+x+ajBy64vp9IqnsfukNZpiRgtG6qk Lc+Gz1ExMwYbHHDJS7WBdPNQ9TDtca6/8mj7SIDsvwjjiBrXFGLOlEg4416DPTFZ6dpt 0t5Q+avU/b+88Zz1Khx8987jhuogDNSONzF8SW7J5r4n71C5LjJO6DzmU5xciVZWDOMZ g0h2CE3ycQRZpP8PSIrLVxy42JkaxrUDvKDTGPcZGTXcfxZ4PtIbGzW0Huf4QcqdTCM9 zNsw== 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=8zPKLrJyYkJHwHaLRXLQhlkNQn1kP8Wkkrare2+IcMg=; b=X0FynTbCR7+ICd3kI3zLySVHBzN/FXedZqRnbQB/D0r9VSAMjlLPDLQomDOs4Vb1Dr 1XkQyl4XJgD+1CCGrJyg4e0woNY1JsdRHRA2S3xDQNNmU1xvNlujpkLYVQFzZDRMyeqk mQyl0PCR8SzO0tDDss3bIbdCZyUmZ+lKZ6hsdU3aAhWTQMUTf5rTOFJ+zTNQV8DKencH 8PUYO/18Oort5oXrd08UyiAYGVIC1KDO6tQ8kIEjxY8gkBNdx1qhtV3RMyZLFzjUqgpK SsFFhIUs0+CCV7w6kSssc6xdNAhVZhWyd6WrU+g7zId+1d68CVoaNurLTVHZx8igcBEy SAbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OWbYzhhc; 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 c13si257723plz.242.2019.08.14.10.20.39; Wed, 14 Aug 2019 10:20:55 -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=OWbYzhhc; 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 S1730682AbfHNRMK (ORCPT + 99 others); Wed, 14 Aug 2019 13:12:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:35680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730671AbfHNRME (ORCPT ); Wed, 14 Aug 2019 13:12:04 -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 EE05F2173E; Wed, 14 Aug 2019 17:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802723; bh=j9MIz3asbyWyrjyFUN/nVZifFgfa9bkPDB77i1lNoIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OWbYzhhcV6xWBJgfqlOPEp4ekGZ5SLFrF3bAH8yAYpNLk0K6+PIPqrNje8hUSnIs/ Dm6yHrT3CYQGXtNzpknp/NqeBngYyh1yI7CBgH80DbjnvXB2DqmglmhRF0rADX5y26 Tn2PpX1Tsv+ueWV8A9YqxWKzrw6wyCj+OSluXLCo= 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.19 66/91] test_firmware: fix a memory leak bug Date: Wed, 14 Aug 2019 19:01:29 +0200 Message-Id: <20190814165752.422980613@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 fd48a15a0710c..a74b1aae74618 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -894,8 +894,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