Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp847903rwb; Thu, 1 Dec 2022 09:05:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf7BbeiZHHZWU4nCdXYUJSmqKaRyRMoVgU8I0pJKTyb4+QUKxFDYPlXRMB6eszZD0c4JlyIn X-Received: by 2002:a17:906:22d6:b0:7c0:9e25:8908 with SMTP id q22-20020a17090622d600b007c09e258908mr7337284eja.673.1669914349869; Thu, 01 Dec 2022 09:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669914349; cv=none; d=google.com; s=arc-20160816; b=UARV6J1BHpDNv5UtsU2NkRsTpjuWQweBmR7L37GEkkBgsmuuhZD+pBpFoYPeAMEDrM EncqmZVx9cg92ypyY7nOVvOvq8fgaou2GoGo0tAmQotBa380WH5PWdNiMojM25OTMbyA jZf5WAnexCHs3q6EBRFsfisyr4nX4SRKQYjQBlFS5g1NyQZcd7Uz7XQV/MJn6ytiYUJf hsam1Uxr+wv3cvRUPWumJphlqAt5wnOtTQGB+kcKMODFmXCxjo595Ok/WflcKVYzaJ7E 0uk9YjqhqUtrgxS7+yNjn/yVWZYh8dMqSGkYn7klyi0Rcd+d1iQ8i3ycocIqIOyYbu64 Og/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=C4pqUiPSopYI0g79Csd25YFtnmIiLrIfWmWGlYpV4ec=; b=wclKzj49/rvwHbpa/6v44CtgM0RVi5IDGSzQoVK1grCzCsqFWrL8OR9YLhkXuKfbX7 D6VjxZrXnqqOKpArWlAh1sM2cKJqylPWY0VqNEjBdSrph5IIFpqoxlvMn4qQAoqm9wup fa7QyfwgX3cqeA0ZYWz5M5joY6Jd4P6Zqv2F6EfSvMDUhMb/4d/VgaOSG0pnKwrfQCj4 /h3Z4lGlsWErOk16HDXoSRUnALrxzn0breHAH+oyG0uFprc8XM6xEExglMb6MDmxBph2 W2psyxgBPzzRumQKsMXBoE2CYn2HWRYeD2NhrOX1MqsOfE0eyEXAOYSQi8Muh0umZHuO aMgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gTttZ1jE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d26-20020a50cd5a000000b0046aff50132asi3719783edj.316.2022.12.01.09.05.29; Thu, 01 Dec 2022 09:05:49 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gTttZ1jE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232228AbiLAQgz (ORCPT + 82 others); Thu, 1 Dec 2022 11:36:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232262AbiLAQgw (ORCPT ); Thu, 1 Dec 2022 11:36:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29109ABA20; Thu, 1 Dec 2022 08:36:52 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BA95C62075; Thu, 1 Dec 2022 16:36:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75632C433D6; Thu, 1 Dec 2022 16:36:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669912611; bh=teeOjCiHN0Fv9n+KoC6rqOlGObhK/vE2PhcSLZFcjpY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gTttZ1jERE9crYJe1Kw/glqQ02k9wSlJRYm0ISYhQw1V+ulysMPAfJ4LccCgxbtNv XCrBfhucsrlZ4dpPCaR+sQJX5x7sPKQP8AXsCQZpqRUNPJQGGRbnuQPCPf1lhSAwH2 e8uXmdgGQyOvvW/52aBhZi1DUCihSWuxwgrRQj4s+CPPvop911k4zw+81GwZkCiaqA BeCmsYyJgNbvRoy13zVGCvYA86yngubBpG1lxINYGJbDhMQ0EIfW2TfbX0QB7ufaEo lK1FEDr85gyy6iTzI5zREoxckN9+ng/UcDxnPH+ZPyhxHN7rXJYGzpBIbbZhzWh7ey euHZfYclxrbcw== Message-ID: Date: Thu, 1 Dec 2022 10:36:48 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH] clk: socfpga: Fix memory leak in socfpga_gate_init() Content-Language: en-US To: Xiu Jianfeng , mturquette@baylibre.com, sboyd@kernel.org Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221123031622.63171-1-xiujianfeng@huawei.com> From: Dinh Nguyen In-Reply-To: <20221123031622.63171-1-xiujianfeng@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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 11/22/22 21:16, Xiu Jianfeng wrote: > Free @socfpga_clk and @ops on the error path to avoid memory leak issue. > > Fixes: a30a67be7b6e ("clk: socfpga: Don't have get_parent for single parent ops") > Signed-off-by: Xiu Jianfeng > --- > drivers/clk/socfpga/clk-gate.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c > index 3e347b9e9eff..0c18c55edf8c 100644 > --- a/drivers/clk/socfpga/clk-gate.c > +++ b/drivers/clk/socfpga/clk-gate.c > @@ -133,8 +133,10 @@ void __init socfpga_gate_init(struct device_node *node) > return; > > ops = kmemdup(&gateclk_ops, sizeof(gateclk_ops), GFP_KERNEL); > - if (WARN_ON(!ops)) > + if (WARN_ON(!ops)) { > + kfree(socfpga_clk); > return; > + } > > rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2); > if (rc) > @@ -182,6 +184,7 @@ void __init socfpga_gate_init(struct device_node *node) > > err = clk_hw_register(NULL, hw_clk); > if (err) { > + kfree(ops); > kfree(socfpga_clk); > return; > } Acked-by: Dinh Nguyen