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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68310C433E7 for ; Fri, 9 Oct 2020 20:59:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 124D022256 for ; Fri, 9 Oct 2020 20:59:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Irh670Dc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 124D022256 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ee/nbLDQeAgPnG4jAglOCohyaAagS697oOa3p9VHPWo=; b=Irh670DcFVp+7VjaFoSIzQ428 vVC5TagaxpKZT2VM6Ty+vtKypuyMih324GUuVnv6ulVW0Brm+1O3K1xIN2FG+znbMqV0h9xKs7vFy 7/TdeSL1fC608EwSNlJowFq4jt15A6GTP1wftXWBvohCiqVSw/njPZfskCHLRwJn+ymTKb0kc0P76 48jWPMqLxVcmjD26QPCm0CM5wvYgXe+SA1nAtdEButqo9+acT0iBEORn6kZERXgd7EOtD6Z0hvpK4 vbuXJIXVWBGFUx3EAdQUF2m7R9DN5ZsM5XiIadv7F3VxqP29A4/ILCphzpHyYgMbyjqq6xtZwQX+j 2S9DI5MuQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQzSc-0003Sf-Dv; Fri, 09 Oct 2020 20:57:54 +0000 Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQzSY-0003RY-O3 for linux-arm-kernel@lists.infradead.org; Fri, 09 Oct 2020 20:57:52 +0000 X-Originating-IP: 90.65.88.165 Received: from localhost (lfbn-lyo-1-1908-165.w90-65.abo.wanadoo.fr [90.65.88.165]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D28B460004; Fri, 9 Oct 2020 20:57:44 +0000 (UTC) Date: Fri, 9 Oct 2020 22:57:44 +0200 From: Alexandre Belloni To: dinghao.liu@zju.edu.cn Subject: Re: Re: [PATCH] rtc: sun6i: Fix memleak in sun6i_rtc_clk_init Message-ID: <20201009205744.GA849573@piout.net> References: <20200823075815.23457-1-dinghao.liu@zju.edu.cn> <6de4a430.8e03.17429fa786d.Coremail.dinghao.liu@zju.edu.cn> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6de4a430.8e03.17429fa786d.Coremail.dinghao.liu@zju.edu.cn> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201009_165750_882800_B611985D X-CRM114-Status: GOOD ( 17.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rtc@vger.kernel.org, Alessandro Zummo , Kangjie Lu , linux-kernel , Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 26/08/2020 16:55:14+0800, dinghao.liu@zju.edu.cn wrote: > > On Sun, Aug 23, 2020 at 3:59 PM Dinghao Liu wrote: > > > > > > When clk_hw_register_fixed_rate_with_accuracy() fails, > > > clk_data should be freed. It's the same for the subsequent > > > error paths. > > > > I suppose you should also unregister the already registered clocks > > in the latter two error paths? > > > > Sounds reasonable. But I find that the existing kernel code takes different > strategies for this case. of_sama5d4_sckc_setup() uses clk_hw_unregister() > after clk_hw_register_fixed_rate_with_accuracy(), while _of_fixed_clk_setup() > uses clk_hw_unregister_fixed_rate(). But at91sam926x_pmc_setup() just does > nothing in this case. I guess you should use clk_hw_unregister_fixed_rate after clk_hw_register_fixed_rate_with_accuracy. clk_hw_unregister will leak the struct clk_fixed_rate. It doesn't matter too much for of_sama5d4_sckc_setup and at91sam926x_pmc_setup because if th clock can't be registered, the platform will not boot. > > Also, tcon_ch1_setup() uses clk_unregister() after clk_register(), while > clk_register_vco_pll() just does nothing. > > So I'm not sure if we should register here and which unregister function to > use. Would you please give me more specific advice about this problem? > > Regards, > Dinghao -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel