Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1778919rwb; Thu, 17 Nov 2022 01:42:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XDLEH6uIwAJ6o6eS2OxMbngy+LWEojQmz0HbFUNNAHOrBZDMoTzJOz4He2CSSZ256dUve X-Received: by 2002:aa7:c046:0:b0:461:54f0:f7dc with SMTP id k6-20020aa7c046000000b0046154f0f7dcmr1453549edo.117.1668678134586; Thu, 17 Nov 2022 01:42:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668678134; cv=none; d=google.com; s=arc-20160816; b=xCi9RqAvSxWL1lbVkPskb2Vl2pTtVs1G/WMBFltruk7KVv1Ws+NER53Mh/NpRL4aHn vdQOHWpe1DtSciU96yCVYLG8zbbd9ja26hdYMeG9bbEyigzMKi/V1QyQYrT42bX9OH3t w6/2GbkXdrSNHnakwWXBI+M7dozuvoK4tz4A/gUdUVOlSme4O+eMEMhFHFYQ779vAOX2 IIMebW9K74GWDlXSPnUJhBzscnTtKvbrdM3+WR3y90HD8Bvc0JDaz/JUWn3vduUMPHj0 Mu96q5GCPiLdfk6iS0WnC6twsUvQRSFpmYwVKo5ZdvgTJcZEDA+BclwuH5uZV/v26jto wcAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=bW8acwexDOHjqYKFBRZETGTUTO2pf3MIffySIiwFTsg=; b=V73plYAZsjHszw/PsEEzv2AbKrYg0BfJ5jCGuWul0QjZ/nbv0UbMQ3rmt8Jg1EemYC zYl2OH3NdXaMk7R9ZtODNuyB50O8xwwEO5+zKTrUXue8MARR9gKsd4/7ACyknE1Rxtkj F5UwYnbyfrDwbzhflDn67frf76hpNrXa9wemrWhVwpB3r8Z/zs1AHppCIIFhFAgV6mM1 A4qDEUv2UnpBtz6Bvq1W69kJC0WaSslOtsVjZNqConn4GIFzGv0qBkI4ZSJrcQsDNh3D 0JATtmaQJ1nJrgIKv6AKgSr2F2bCIdaAmaXY1NSsYrKK+r4gfTOp3tRNRgA4pIsB/tII 2qLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz20-20020a170906f2d400b007ae3958c7c9si167409ejb.999.2022.11.17.01.41.53; Thu, 17 Nov 2022 01:42:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239798AbiKQJNh (ORCPT + 91 others); Thu, 17 Nov 2022 04:13:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239794AbiKQJNd (ORCPT ); Thu, 17 Nov 2022 04:13:33 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B49E72B197 for ; Thu, 17 Nov 2022 01:13:28 -0800 (PST) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovaxP-0005PI-W9; Thu, 17 Nov 2022 10:13:16 +0100 Received: from mfe by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1ovaxP-0007Fb-E1; Thu, 17 Nov 2022 10:13:15 +0100 Date: Thu, 17 Nov 2022 10:13:15 +0100 From: Marco Felsch To: Zheng Yongjun Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, festevam@gmail.com, linux-imx@nxp.com, kernel@pengutronix.de Subject: Re: [PATCH] ARM: mxs: fix memory leak in mxs_machine_init() Message-ID: <20221117091315.wwojwl7vhp43k63v@pengutronix.de> References: <20221117062011.84602-1-zhengyongjun3@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221117062011.84602-1-zhengyongjun3@huawei.com> User-Agent: NeoMutt/20180716 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22-11-17, Zheng Yongjun wrote: > 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 > --- > 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 25c9d184fa4c..1c57ac401649 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.17.1 > > >