From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FC7CC4332F for ; Mon, 5 Dec 2022 19:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233832AbiLETYE (ORCPT ); Mon, 5 Dec 2022 14:24:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233835AbiLETXn (ORCPT ); Mon, 5 Dec 2022 14:23:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C4172B1B3 for ; Mon, 5 Dec 2022 11:18:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E9859B8120F for ; Mon, 5 Dec 2022 19:18:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C504C433D6; Mon, 5 Dec 2022 19:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670267902; bh=IUazWeTxobJECcYh3z89Bl/jOzcwT+93aRzEwi95fyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqyfjK+3YYq8Ke87IK+okxvxy4xCafoSfGTJM2vB6WNVfDMX6mXk3FZ4Kr8tpPHT7 B6KZhI/t3UyMbn3F6Z/6roRhSVllM5h3/cj/q/wrpO9JAMxZKITqRoqZGwDWzexRB8 G+Uri8PWzcOKQ/vNNe1LbDEpYxMNvJQP8TDuiI0c= 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 4.19 016/105] ARM: mxs: fix memory leak in mxs_machine_init() Date: Mon, 5 Dec 2022 20:08:48 +0100 Message-Id: <20221205190803.684284704@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221205190803.124472741@linuxfoundation.org> References: <20221205190803.124472741@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 1c6062d240c8..4063fc1f435b 100644 --- a/arch/arm/mach-mxs/mach-mxs.c +++ b/arch/arm/mach-mxs/mach-mxs.c @@ -393,8 +393,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