All of lore.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-clk@vger.kernel.org, Chao Xie <chao.xie@marvell.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()
Date: Wed, 27 Sep 2017 07:26:23 +0000	[thread overview]
Message-ID: <4dbb54c0-e2f9-b021-fe0a-35b39bff8865@users.sourceforge.net> (raw)
In-Reply-To: <051d7ba6-e3cc-8354-8315-93fe039dd2ce@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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


WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-clk@vger.kernel.org, Chao Xie <chao.xie@marvell.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()
Date: Wed, 27 Sep 2017 09:26:23 +0200	[thread overview]
Message-ID: <4dbb54c0-e2f9-b021-fe0a-35b39bff8865@users.sourceforge.net> (raw)
In-Reply-To: <051d7ba6-e3cc-8354-8315-93fe039dd2ce@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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

  parent reply	other threads:[~2017-09-27  7:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27  7:23 [PATCH 0/3] MMP clock: Adjustments for seven function implementations SF Markus Elfring
2017-09-27  7:23 ` SF Markus Elfring
2017-09-27  7:25 ` [PATCH 1/3] clk/mmp: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-09-27  7:25   ` SF Markus Elfring
2017-11-14  1:59   ` Stephen Boyd
2017-11-14  1:59     ` Stephen Boyd
2017-09-27  7:26 ` SF Markus Elfring [this message]
2017-09-27  7:26   ` [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix() SF Markus Elfring
2017-11-14  1:59   ` Stephen Boyd
2017-11-14  1:59     ` Stephen Boyd
2017-09-27  7:27 ` [PATCH 3/3] clk/mmp: Adjust 12 checks for null pointers SF Markus Elfring
2017-09-27  7:27   ` SF Markus Elfring
2017-09-27  9:26   ` Sylwester Nawrocki
2017-09-27  9:26     ` Sylwester Nawrocki
2017-11-14  1:59   ` Stephen Boyd
2017-11-14  1:59     ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4dbb54c0-e2f9-b021-fe0a-35b39bff8865@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=chao.xie@marvell.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.