From patchwork Fri Dec 22 09:23:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13503112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E727C41535 for ; Fri, 22 Dec 2023 09:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:Subject:References:Cc: To:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3v28nC4zTD3IkIPCyvOldsRY84mILC5OPGJBVemr/OQ=; b=axKSZ1C6SSS6dQ 6dZ7flt+nmzbNTNrGXKOLWD2Wfvferl2rbsnxChieaKfxlWJU1f6ufqp9xdEF05XIBjnwe+yDaxiP zWYkU38s1bvmF5ID7wg4QDcNB+AJlZDwypJ10kT9tVWDgJI1j1WTWvhqdHk2cCO/kwifaucncR9k6 W380QIfF0HtBMA6iIsMk/M6LlXn8LrwxAJ71bwLpbFl/t5syNFoE6qjF7zPi9ePppFpHd1GWJLGSj WZusbv8UpHEBm8lYwDV7QV9o7xh2z8tXt993rsQs7/daliFKiWOXjgRSXctrBWuV/w27gHnDsEl5e AY6tBzOFkcfoDmY8AYfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGbko-005Poh-05; Fri, 22 Dec 2023 09:23:38 +0000 Received: from mout.web.de ([217.72.192.78]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGbkl-005PoM-1g for linux-arm-kernel@lists.infradead.org; Fri, 22 Dec 2023 09:23:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1703236995; x=1703841795; i=markus.elfring@web.de; bh=3ig45DHXiib9kb5XvzHMPJQLjNR+DPC4+AqNcZPSRqU=; h=X-UI-Sender-Class:Date:To:Cc:References:Subject:From: In-Reply-To; b=TtPklQtkl8+oC25Zf6mbd5TyMgo+6lOKU0OQ6BPWEXukGcGhAXOsA2ujSMIG/Gap 0FjgjScqL6XlK4aTVnaZ3HJHxRZL1aQsjq823KBj8V91BGqSR1LjzMCqrL6/2et+8 8C8s+MlA3/d5BFFoRC67FqXKoQNXhHKlEk/d2kAn+xFrqfFkzBo/8AR3PF3FlETlJ woXXx67SuJbhvZELQHW62xpEIZLkBVJ3+qx6QwKbhB1PqifE/yC6Kq4i7xceVXgG0 X8LxdwPsXOIqB60V6Zl8O6AKnnj6wJnHsgviuBOYQ/yTm8XoPX25SZflNmBJ3S3NK mnVgOzkuBZcCKFkc0w== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MYu1C-1rlM3f2aSe-00VDQ7; Fri, 22 Dec 2023 10:23:15 +0100 Message-ID: <0e906ec6-fe73-4dbd-b555-a2c03b6e1030@web.de> Date: Fri, 22 Dec 2023 10:23:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Kuan-Wei Chiu , Abel Vesa , Fabio Estevam , Michael Turquette , Peng Fan , Sascha Hauer , Shawn Guo , Stephen Boyd , kernel@pengutronix.de, linux-imx@nxp.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: LKML , cocci@inria.fr References: <20231210171907.3410922-1-visitorckw@gmail.com> Subject: [PATCH] clk: imx: scu: Use common error handling code in __imx_clk_gpr_scu() Content-Language: en-GB From: Markus Elfring In-Reply-To: <20231210171907.3410922-1-visitorckw@gmail.com> X-Provags-ID: V03:K1:bbmJkcNnDotFtiTs26dlJsi1vk2huEHcKia+9MBq1a39yWTPgMS jxhFdyB5D51I7V2INVG9+gNjPJfG3zdMnWzRIcEGYjtCXTTONE0KJFmWATS5l+g4+RrFe6t DKdM+bHpWvYpqx44h6Wp9m6v153RG55/R0H/TVxNvJ+j2z+15+3ZnVwS2zp+LQsm4Cnl4xp h2vs1+itu0+fUskgWwFQw== UI-OutboundReport: notjunk:1;M01:P0:zIfadAQeSq0=;U6exYvAg99UQJpr3sFbuqp6wy5Y CzjzhyjdOylHww44g9D/ghe4CCwUAJ8X4Qrp+cOuxiGcvCMon3Z3NT+OchSlMoBNgl7S1w/bT w21jCQqNaSib2HSsOVCmrtMqmCV5XSbdKUPpc/vDoO8/liVbmrC5RK5r9oiygrPVhQ/4Smu4R 2E4/sTzLKZxxdgi2Q3OhKc/Qjq8RNnBc+xkfFTL/ELmNXQYe4cl9sPBXnfrgNun6VdZ7DFCFD sgrnOPBDY6x5LuumfxDBv79iIebR/OEjqIsNWc32xt+xBRQft4QxPT1kK/XjsJXqQo9q5V15s mMeEcee8BfcruREOc8JOQUi1OFu/YJMbgNL9Qn/g4Q948GnL+PPUO45LhWbBMiefoO59AwTuz +OUd5WRPfKpQobxz2X8VA8r+7vSkHZEx8eoIBRhJEazt/q7Y2rsW1MSKOimfOhCSBvxLSpyPq 69Iga/Ok0uZ0hwf6+bsJksn1VT1CJvgp7s9lbbvEhSkqnmUpZBiZ0wegh7EAxE9vVB5/eGKnb zcqunlyunsIgHCMgIpTw3Q04GCzTSnUQUTC6UZpv6G7ob8ABWv/j04NCRfc/+hGrianQEe8rn ON5sYyyGZi6BYrg7rodUEw0FNKKfxSIp2W5ZZxWNALPzbc8G4uyjT55x4kiuImWAJ/TJls++r ghulBoXWNBFC3X+kKOW8/Zb0OV+CUnjLFsewyKU07UqjXSQ6OwsQ7nZQvRFdPUAzFQ04HFbsW 8reCagSpVVsaHYOLOsNLL+L1uiQIDjDfKnceKE+cFZy0n18xSkgyEzBIEUw/AHSEROeECcAVZ 9wBStI85eq529BwxCNeu6ljkQCebwd1cQLB669/DS8SvWZRj5GNVkqvETh68RuCEojcD78eJx LzVzBSh3bdLaVbgU2BU8zp2Z/aqsi14cTVHCSmqbZ/XfQ4uEmOpdDsuFTaBcu8sNYCd5q5Zo8 NfNhaQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231222_012336_034640_9B4224E4 X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Markus Elfring Date: Fri, 22 Dec 2023 10:05:32 +0100 Use another label so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring --- drivers/clk/imx/clk-scu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.43.0 diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index e48a904c0013..4ca9dccf3d3b 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -882,19 +882,19 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na return ERR_PTR(-ENOMEM); if (!imx_scu_clk_is_valid(rsrc_id)) { - kfree(clk_node); - return ERR_PTR(-EINVAL); + ret = -EINVAL; + goto free_clk_node; } if (!imx_clk_is_resource_owned(rsrc_id)) { - kfree(clk_node); - return NULL; + ret = 0; + goto free_clk_node; } clk = kzalloc(sizeof(*clk), GFP_KERNEL); if (!clk) { - kfree(clk_node); - return ERR_PTR(-ENOMEM); + ret = -ENOMEM; + goto free_clk_node; } clk->rsrc_id = rsrc_id; @@ -922,6 +922,7 @@ struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_na ret = clk_hw_register(NULL, hw); if (ret) { kfree(clk); +free_clk_node: kfree(clk_node); hw = ERR_PTR(ret); } else {