From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5756115C85 for ; Mon, 5 Dec 2022 19:40:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF627C433D6; Mon, 5 Dec 2022 19:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670269229; bh=wrLthqlyshnHPFKjFIHsm8iKLayn4pB3Hm05tUTGqKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i300KjEDuh2Aa5s7jAaAcd97r1gfC4AdTjyCx7DLB1gBdOivKormLc4nm1zqatw5L eQXIJLOSzxvRTQB5f0t77LEHmQbfRQ4gqR8Zvq0ZPzk83IA3hNfiaygxzftxMYsyYH tGZccfVde0+4Hz/h2DNdi1k9SQUrzppbE4SOy3ek= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zheng Yongjun , Marco Felsch , Shawn Guo , Sasha Levin Subject: [PATCH 5.4 023/153] ARM: mxs: fix memory leak in mxs_machine_init() Date: Mon, 5 Dec 2022 20:09:07 +0100 Message-Id: <20221205190809.402862744@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221205190808.733996403@linuxfoundation.org> References: <20221205190808.733996403@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Zheng Yongjun [ Upstream commit f31e3c204d1844b8680a442a48868af5ac3d5481 ] If of_property_read_string() failed, 'soc_dev_attr' should be freed before return. Otherwise there is a memory leak. Fixes: 2046338dcbc6 ("ARM: mxs: Use soc bus infrastructure") Signed-off-by: Zheng Yongjun Reviewed-by: Marco Felsch Signed-off-by: Shawn Guo Signed-off-by: Sasha Levin --- arch/arm/mach-mxs/mach-mxs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c index c109f47e9cbc..a687e83ad604 100644 --- a/arch/arm/mach-mxs/mach-mxs.c +++ b/arch/arm/mach-mxs/mach-mxs.c @@ -387,8 +387,10 @@ static void __init mxs_machine_init(void) root = of_find_node_by_path("/"); ret = of_property_read_string(root, "model", &soc_dev_attr->machine); - if (ret) + if (ret) { + kfree(soc_dev_attr); return; + } soc_dev_attr->family = "Freescale MXS Family"; soc_dev_attr->soc_id = mxs_get_soc_id(); -- 2.35.1