linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@codeaurora.org>
To: Sergej Sawazki <ce3a@gmx.de>, mturquette@baylibre.com, jsarha@ti.com
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH v4 3/4] clk: add gpio controlled clock multiplexer
Date: Mon, 06 Jul 2015 17:17:54 -0700	[thread overview]
Message-ID: <559B1AB2.10901@codeaurora.org> (raw)
In-Reply-To: <1435501496-25761-4-git-send-email-ce3a@gmx.de>

On 06/28/2015 07:24 AM, Sergej Sawazki wrote:
> Add a common clock driver for basic gpio controlled clock multiplexers.
> This driver can be used for devices like 5V41068A or 831721I from IDT
> or for discrete multiplexer circuits. The 'select' pin selects one of
> two parent clocks.
>
> Cc: Jyri Sarha <jsarha@ti.com>
> Signed-off-by: Sergej Sawazki <ce3a@gmx.de>
> ---
>

And this doesn't do a good job of freeing stuff on failure paths. I
squashed this in

---8<---

diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index 29d8917e8eeb..c0d202c24a97 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -126,6 +126,9 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name,
 		if (err != -EPROBE_DEFER)
 			pr_err("%s: %s: Error requesting clock control gpio %u\n",
 					__func__, name, gpio);
+		if (!dev)
+			kfree(clk_gpio);
+
 		return ERR_PTR(err);
 	}
 
@@ -147,8 +150,8 @@ static struct clk *clk_register_gpio(struct device *dev, const char *name,
 		return clk;
 
 	if (!dev) {
-		kfree(clk_gpio);
 		gpiod_put(clk_gpio->gpiod);
+		kfree(clk_gpio);
 	}
 
 	return clk;
@@ -256,13 +259,13 @@ static struct clk *of_clk_gpio_delayed_register_get(
 
 	clk = data->clk_register_get(data->node->name, parent_names,
 			num_parents, gpio, of_flags & OF_GPIO_ACTIVE_LOW);
-	if (IS_ERR(clk)) {
-		mutex_unlock(&data->lock);
-		return clk;
-	}
+	if (IS_ERR(clk))
+		goto out;
 
 	data->clk = clk;
+out:
 	mutex_unlock(&data->lock);
+	kfree(parent_names);
 
 	return clk;
 }

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2015-07-07  0:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28 14:24 [PATCH v4 0/4] clk: add gpio controlled clock multiplexer Sergej Sawazki
2015-06-28 14:24 ` [PATCH v4 1/4] clk: gpio-gate: Include export.h instead of module.h Sergej Sawazki
2015-06-28 14:24 ` [PATCH v4 2/4] clk: gpio-gate: Stay silent on EPROBE_DEFER Sergej Sawazki
2015-06-28 14:24 ` [PATCH v4 3/4] clk: add gpio controlled clock multiplexer Sergej Sawazki
2015-07-07  0:17   ` Stephen Boyd [this message]
2015-06-28 14:24 ` [PATCH v4 4/4] clk: Rename clk-gpio-gate.c to clk-gpio.c Sergej Sawazki
2015-07-02 21:38   ` Stephen Boyd
2015-07-02 21:39 ` [PATCH v4 0/4] clk: add gpio controlled clock multiplexer 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=559B1AB2.10901@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=ce3a@gmx.de \
    --cc=jsarha@ti.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).