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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 9E9F7C433E2 for ; Wed, 31 Mar 2021 08:19:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6330D619E3 for ; Wed, 31 Mar 2021 08:19:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234351AbhCaISx (ORCPT ); Wed, 31 Mar 2021 04:18:53 -0400 Received: from esa.microchip.iphmx.com ([68.232.153.233]:63834 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234317AbhCaISr (ORCPT ); Wed, 31 Mar 2021 04:18:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1617178727; x=1648714727; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=2nV0mXiyWztHWYThPphmbciYbzLzkc35sM0Dekg54Lk=; b=qhlFR/3QUdobCaVbmN6+qy+2MNHnDq61f0no19cxtqk1A29Spx8ugIiR yP6ikWNfiKpIRgSa4McjtNCx26D4jE+5dpkCvRpakkh8pZDRg2nXKCcTr EdVjxa/NqZjGbsEmo9EoKdMH9edYnSBqKkBRRzL8d3dY5WtRj/Zsny5uZ Unm112ziGw9i/lKisZ2a7IqB5l+Tab9RkHLH7fkC0M0EvLOj98DFpZJwh bzcIRKppQZ7H4jLjWY616WNnl5dQXLuyBW6B25r3hABfu413S8nr9aL1a 8ef3zAR8PqIo0ZJxHMGoV2Waah8ktDsx86VJXdyQl3ajQJetjLY1ad2cO g==; IronPort-SDR: 4EpDx81z0VAggYIKFLHNgy52EPo4trXaZJI5T2YSpChuh1AGjlgnmdZSFxxwQIqsv2i6k+LGN9 1G2yAhPZsH7m862FcuZgbqm9Pu/vC1QF5dUQYUoduiPDO/HC/EFvQiZN7OxSvKIKPn7zpeTO1w 4aNdmKvGPpwJm+ExeEHkXk7RbQ49jyBgGfoiLMOFvGMvBeXekGSuioAKo214wbS1rYfQcYc+u1 u+fnq5JAwwhdaIjWI2WIPtbHkF/fZidbQPrSg0FqLiCZiE3VAdB0VtfOb7n8UVcV1V40RZEPH3 d+A= X-IronPort-AV: E=Sophos;i="5.81,293,1610434800"; d="scan'208";a="114810110" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 31 Mar 2021 01:18:47 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 31 Mar 2021 01:18:44 -0700 Received: from [10.171.246.91] (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Wed, 31 Mar 2021 01:18:42 -0700 Subject: Re: [PATCH] power: reset: at91-reset: free resources on exit path To: Claudiu Beznea , , , CC: , , , kernel test robot , "Dan Carpenter" References: <20210209110109.906034-1-claudiu.beznea@microchip.com> From: Nicolas Ferre Organization: microchip Message-ID: Date: Wed, 31 Mar 2021 10:18:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210209110109.906034-1-claudiu.beznea@microchip.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/02/2021 at 12:01, Claudiu Beznea wrote: > Free resources on exit path (failure path of probe and remove). I'm not sure we can use this driver as a module anyway. Otherwise, it looks fine, but isn't it possible to use devm_of_iomap(), even in loop, and avoid having to deal with exit path? > Reported-by: kernel test robot > Reported-by: Dan Carpenter > Signed-off-by: Claudiu Beznea > --- > drivers/power/reset/at91-reset.c | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > > diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c > index 3ff9d93a5226..2ff7833153b6 100644 > --- a/drivers/power/reset/at91-reset.c > +++ b/drivers/power/reset/at91-reset.c > @@ -206,7 +206,8 @@ static int __init at91_reset_probe(struct platform_device *pdev) > if (!reset->ramc_base[idx]) { > dev_err(&pdev->dev, "Could not map ram controller address\n"); > of_node_put(np); > - return -ENODEV; > + ret = -ENODEV; > + goto unmap; > } > idx++; > } > @@ -218,13 +219,15 @@ static int __init at91_reset_probe(struct platform_device *pdev) > reset->args = (u32)match->data; > > reset->sclk = devm_clk_get(&pdev->dev, NULL); > - if (IS_ERR(reset->sclk)) > - return PTR_ERR(reset->sclk); > + if (IS_ERR(reset->sclk)) { > + ret = PTR_ERR(reset->sclk); > + goto unmap; > + } > > ret = clk_prepare_enable(reset->sclk); > if (ret) { > dev_err(&pdev->dev, "Could not enable slow clock\n"); > - return ret; > + goto unmap; > } > > platform_set_drvdata(pdev, reset); > @@ -239,21 +242,33 @@ static int __init at91_reset_probe(struct platform_device *pdev) > ret = register_restart_handler(&reset->nb); > if (ret) { > clk_disable_unprepare(reset->sclk); > - return ret; > + goto unmap; > } > > at91_reset_status(pdev, reset->rstc_base); > > return 0; > + > +unmap: > + iounmap(reset->rstc_base); > + for (idx = 0; idx < ARRAY_SIZE(reset->ramc_base); idx++) > + iounmap(reset->ramc_base[idx]); But if we keep this loop, I have the feeling that some kind of "of_node_put()" is needed as well. > + > + return ret; > } > > static int __exit at91_reset_remove(struct platform_device *pdev) > { > struct at91_reset *reset = platform_get_drvdata(pdev); > + int idx; > > unregister_restart_handler(&reset->nb); > clk_disable_unprepare(reset->sclk); > > + iounmap(reset->rstc_base); > + for (idx = 0; idx < ARRAY_SIZE(reset->ramc_base); idx++) > + iounmap(reset->ramc_base[idx]); Ditto > + > return 0; > } > > -- Nicolas Ferre 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=-15.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 86BF7C433DB for ; Wed, 31 Mar 2021 08:20:56 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 24AB061883 for ; Wed, 31 Mar 2021 08:20:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24AB061883 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.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=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:CC:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CnuvBllVW4GsTqTqQm+r8zWzn1OkH1/amNupsGxeeHI=; b=WoTU1imo3SqZ1ju9eg/EkTHAv 3QI6H+FvgOqyFKcXMbpAXtp95bzvHmXUtbnD6j14lWQ4bE9Y0d9LNs37Xg2Cf7rKRCmQaKtSKkyXk czOQsNtfJ4+utWOGADXDAQuVxFsrWTaTMw8rG5IA9mZeSj3/vRLifTo28xV6tJfFhEqSLtCODCp73 UU/u2vMqE9BpohvXu3qZ/aI/sNntlYQ/R0cR5+WXeX8IpW6ZI2YfvRWu32JIKgAUtzHbb60NHWYbp vQdjcFSNB4Y9GsZUKEhKDiVMDCbPb+ER1hXH9Hx9ZoU6cIw1wkDy8N6XqkhhY2+1vpUWFClu8Ak8h X+ZpKv1bQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lRW44-005vCM-UJ; Wed, 31 Mar 2021 08:19:01 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lRW3t-005v8G-3z for linux-arm-kernel@lists.infradead.org; Wed, 31 Mar 2021 08:18:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1617178729; x=1648714729; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=2nV0mXiyWztHWYThPphmbciYbzLzkc35sM0Dekg54Lk=; b=gsXEet14qm4JuhJHqRR9jfQTJVuMgwRWA4vTC6V7NBNv+2yfTeYo0bpw 6nCmiWfk3BWKXfQnPTXVjDWKnN5oDkuMXOTY4fAw/5NcCz6V7e4/eJjvG Av+KHEBhBS5u+v4CfKNpGJBn8PPuXG+G4cVMFkICcSrZe2+I1134fRQQ4 WKQXlpqT/egdfXN5bt48mpa0nfdNmGj7oG+SvJ4qtpdU/LuWr6RlUbK9K I49JP6daCTcnC+PCV2LtMKFi26ZpJJer+7GPIuXJolyztiU1Ag3ijfaQS ZWJfQU2tmtlypYCr4omasO3Otg7uD0ee5WGs2xoSBKxQvFbNJhwBQ768D A==; IronPort-SDR: 4EpDx81z0VAggYIKFLHNgy52EPo4trXaZJI5T2YSpChuh1AGjlgnmdZSFxxwQIqsv2i6k+LGN9 1G2yAhPZsH7m862FcuZgbqm9Pu/vC1QF5dUQYUoduiPDO/HC/EFvQiZN7OxSvKIKPn7zpeTO1w 4aNdmKvGPpwJm+ExeEHkXk7RbQ49jyBgGfoiLMOFvGMvBeXekGSuioAKo214wbS1rYfQcYc+u1 u+fnq5JAwwhdaIjWI2WIPtbHkF/fZidbQPrSg0FqLiCZiE3VAdB0VtfOb7n8UVcV1V40RZEPH3 d+A= X-IronPort-AV: E=Sophos;i="5.81,293,1610434800"; d="scan'208";a="114810110" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 31 Mar 2021 01:18:47 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 31 Mar 2021 01:18:44 -0700 Received: from [10.171.246.91] (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Wed, 31 Mar 2021 01:18:42 -0700 Subject: Re: [PATCH] power: reset: at91-reset: free resources on exit path To: Claudiu Beznea , , , CC: , , , kernel test robot , "Dan Carpenter" References: <20210209110109.906034-1-claudiu.beznea@microchip.com> From: Nicolas Ferre Organization: microchip Message-ID: Date: Wed, 31 Mar 2021 10:18:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210209110109.906034-1-claudiu.beznea@microchip.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210331_091849_709365_BEB498BC X-CRM114-Status: GOOD ( 22.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 09/02/2021 at 12:01, Claudiu Beznea wrote: > Free resources on exit path (failure path of probe and remove). I'm not sure we can use this driver as a module anyway. Otherwise, it looks fine, but isn't it possible to use devm_of_iomap(), even in loop, and avoid having to deal with exit path? > Reported-by: kernel test robot > Reported-by: Dan Carpenter > Signed-off-by: Claudiu Beznea > --- > drivers/power/reset/at91-reset.c | 25 ++++++++++++++++++++----- > 1 file changed, 20 insertions(+), 5 deletions(-) > > diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c > index 3ff9d93a5226..2ff7833153b6 100644 > --- a/drivers/power/reset/at91-reset.c > +++ b/drivers/power/reset/at91-reset.c > @@ -206,7 +206,8 @@ static int __init at91_reset_probe(struct platform_device *pdev) > if (!reset->ramc_base[idx]) { > dev_err(&pdev->dev, "Could not map ram controller address\n"); > of_node_put(np); > - return -ENODEV; > + ret = -ENODEV; > + goto unmap; > } > idx++; > } > @@ -218,13 +219,15 @@ static int __init at91_reset_probe(struct platform_device *pdev) > reset->args = (u32)match->data; > > reset->sclk = devm_clk_get(&pdev->dev, NULL); > - if (IS_ERR(reset->sclk)) > - return PTR_ERR(reset->sclk); > + if (IS_ERR(reset->sclk)) { > + ret = PTR_ERR(reset->sclk); > + goto unmap; > + } > > ret = clk_prepare_enable(reset->sclk); > if (ret) { > dev_err(&pdev->dev, "Could not enable slow clock\n"); > - return ret; > + goto unmap; > } > > platform_set_drvdata(pdev, reset); > @@ -239,21 +242,33 @@ static int __init at91_reset_probe(struct platform_device *pdev) > ret = register_restart_handler(&reset->nb); > if (ret) { > clk_disable_unprepare(reset->sclk); > - return ret; > + goto unmap; > } > > at91_reset_status(pdev, reset->rstc_base); > > return 0; > + > +unmap: > + iounmap(reset->rstc_base); > + for (idx = 0; idx < ARRAY_SIZE(reset->ramc_base); idx++) > + iounmap(reset->ramc_base[idx]); But if we keep this loop, I have the feeling that some kind of "of_node_put()" is needed as well. > + > + return ret; > } > > static int __exit at91_reset_remove(struct platform_device *pdev) > { > struct at91_reset *reset = platform_get_drvdata(pdev); > + int idx; > > unregister_restart_handler(&reset->nb); > clk_disable_unprepare(reset->sclk); > > + iounmap(reset->rstc_base); > + for (idx = 0; idx < ARRAY_SIZE(reset->ramc_base); idx++) > + iounmap(reset->ramc_base[idx]); Ditto > + > return 0; > } > > -- Nicolas Ferre _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel