clk: mmp: Use common error handling code in mmp_clk_register_mix()
authorMarkus Elfring <elfring@users.sourceforge.net>
Tue, 26 Sep 2017 20:33:18 +0000 (22:33 +0200)
committerStephen Boyd <sboyd@codeaurora.org>
Tue, 14 Nov 2017 01:40:33 +0000 (17:40 -0800)
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>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/mmp/clk-mix.c

index 1ae532d..b2471fb 100644 (file)
@@ -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);
 }