Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1740451 > unrolled thread

[PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-09-27 09:30 +0200
Last post2017-09-27 09:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/3] clk/mmp: Use common error handling code in  mmp_clk_register_mix() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-27 09:30 +0200

#1740451 — [PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-09-27 09:30 +0200
Subject[PATCH 2/3] clk/mmp: Use common error handling code in mmp_clk_register_mix()
Message-ID<uueX7-7EN-15@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web