Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752149AbdI0H0e (ORCPT ); Wed, 27 Sep 2017 03:26:34 -0400 Received: from mout.web.de ([212.227.15.4]:56759 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750917AbdI0H0c (ORCPT ); Wed, 27 Sep 2017 03:26:32 -0400 Subject: [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix() From: SF Markus Elfring To: linux-clk@vger.kernel.org, Chao Xie , Michael Turquette , Stephen Boyd Cc: LKML , kernel-janitors@vger.kernel.org References: <051d7ba6-e3cc-8354-8315-93fe039dd2ce@users.sourceforge.net> Message-ID: <4dbb54c0-e2f9-b021-fe0a-35b39bff8865@users.sourceforge.net> Date: Wed, 27 Sep 2017 09:26:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <051d7ba6-e3cc-8354-8315-93fe039dd2ce@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:ooFoDKmZgvpVAZFGSEtl7gwCL8UCiMxOpBGKlacm3KVmArIBc8e qzlDhAzOIsy5whPUfpKR1FxKLeOrM+4jbh3+S4OG30I6ej9pMRdBll4q0nm++Fe5h/lSQid ssVs2XnmR6oQCrvSowT9HHPSILYK2TZUs4Ey6qgv0bZwWVdRKDovbOu7Qvxxoqk3OpnIucq 4XPMe1w69Ld1HS6b+sWTQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:OBG17FCwc1M=:fDzhx4hTXkUP/nVMkqfreD 6KjjoRRTt/Fy5ea+aRqxyL3gcVCQXc+xpJ1cYLpXM8jIQ5byQX4RuCt/DdSYdVc7GUiyWlCk5 FpNPPB6T9WWDiQOv+H6ZEhHcxBRKlBKa4uPfjNL2mgVO6JmKunbzqC6V0L5UNBXv4aJci3x+Y u7vvM+bSwEZQjcjbd34n4Bn5HnJyDlTJlTXCTfZ5bxfXaFauwHeCSF5Tfu45f3HD7AhRL6KrF eYtLXG0vMY+++GIIzlOUMCKot56Km/NGINdlVns76vyogpUaMJpzVYTgxEag7cmmY+2oDEpWd aUiRgq4lTuH1nWQ/t2qTstw/sIwrrfoeFtKt29TIo0/FA88Z9Kl+RsiyB+TqpRrMwpMg+m/75 Fi25UuAtGgsSaEVpEEqsKhClzGvgo6lrnlDv4U+rg+t6m1SWgP31pHNjY47KYF7VUx6fQEXHy LQfeo/iLxR6owNYfWl/Avo7bckcf9CDHBBGGmoMkOb10xy8+ycDvEJHtkIvQMICDUKSzgfyv8 thlfDVALitEbK8E9kmHO7uipEfLmJX97qf15Bb4d9labLsLNvFEvZfjHCSnpR0lkdZmjin8GB vfSoEGgPzzEgcw4tP92V/iXa8Lkd009B0NJ/6wmN1lA7FTxqbpchptF9jL8guAkoRxjqBzdVY 4xwCKYi8f18up8udqo86OLW8mcmdxcSRpuH4pN2qjhCjPLaCRwAw8KLaKGyLdp5R4quITmiiJ Qytr91mqP6u0O8AVLLoP/b/gy/+SmtIC20Q7eX4EH+Yfj+Z6i1pNZv7nbp9bsbmbAMfR54e0K JQFP/lOhazGczTRoBcBCb47WaOtQ1bjs6UrziBT+M2WOXJ2eQ8= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1293 Lines: 50 From: Markus Elfring Date: Tue, 26 Sep 2017 22:33:18 +0200 Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring --- drivers/clk/mmp/clk-mix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c index 1ae532df20f7..b2471fb369f1 100644 --- a/drivers/clk/mmp/clk-mix.c +++ b/drivers/clk/mmp/clk-mix.c @@ -464,10 +464,9 @@ struct clk *mmp_clk_register_mix(struct device *dev, if (config->table) { table_bytes = sizeof(*config->table) * config->table_size; mix->table = kmemdup(config->table, table_bytes, GFP_KERNEL); - if (!mix->table) { - kfree(mix); - return ERR_PTR(-ENOMEM); - } + if (!mix->table) + goto free_mix; + mix->table_size = config->table_size; } @@ -477,8 +476,7 @@ struct clk *mmp_clk_register_mix(struct device *dev, GFP_KERNEL); if (!mix->mux_table) { kfree(mix->table); - kfree(mix); - return ERR_PTR(-ENOMEM); + goto free_mix; } } @@ -502,4 +500,8 @@ struct clk *mmp_clk_register_mix(struct device *dev, } return clk; + +free_mix: + kfree(mix); + return ERR_PTR(-ENOMEM); } -- 2.14.1