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 7591915C83 for ; Mon, 5 Dec 2022 19:15:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDA9CC43470; Mon, 5 Dec 2022 19:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1670267758; bh=IUazWeTxobJECcYh3z89Bl/jOzcwT+93aRzEwi95fyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KX45o4a2Y0VbcdBTNW4W81JGOeyu5E/oK/a7Or4x2h5dnPLeg7JiQl4ZfRU0nWvzZ 1eGSpYTX9ABzrKyzXmFd+alDKoRztAHdvXkP0iWsGQNzd+ed99L9qimIIM6Kezowr2 I8MazlLogDyp9sfK714BpJhqcxHF+FeqLaPqhVPY= 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.14 13/77] ARM: mxs: fix memory leak in mxs_machine_init() Date: Mon, 5 Dec 2022 20:09:04 +0100 Message-Id: <20221205190801.334306536@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221205190800.868551051@linuxfoundation.org> References: <20221205190800.868551051@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 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