From: Kishon Vijay Abraham I <kishon@ti.com>
To: <gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>
Cc: <kishon@ti.com>, Sachin Kamat <sachin.kamat@linaro.org>
Subject: [PATCH 1/3] drivers: phy: Fix memory leak
Date: Fri, 6 Dec 2013 17:51:18 +0530 [thread overview]
Message-ID: <1386332480-31671-2-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1386332480-31671-1-git-send-email-kishon@ti.com>
From: Sachin Kamat <sachin.kamat@linaro.org>
'phy' was not being freed upon error in one of the cases.
Adjust the 'goto's to fix this.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/phy/phy-core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 03cf8fb..712b358 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -453,7 +453,7 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
if (id < 0) {
dev_err(dev, "unable to get id\n");
ret = id;
- goto err0;
+ goto err1;
}
device_initialize(&phy->dev);
@@ -468,11 +468,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
ret = dev_set_name(&phy->dev, "phy-%s.%d", dev_name(dev), id);
if (ret)
- goto err1;
+ goto err2;
ret = device_add(&phy->dev);
if (ret)
- goto err1;
+ goto err2;
if (pm_runtime_enabled(dev)) {
pm_runtime_enable(&phy->dev);
@@ -481,11 +481,11 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
return phy;
-err1:
+err2:
ida_remove(&phy_ida, phy->id);
put_device(&phy->dev);
+err1:
kfree(phy);
-
err0:
return ERR_PTR(ret);
}
--
1.7.10.4
next prev parent reply other threads:[~2013-12-06 12:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 12:21 [PATCH 0/3] PHY: Fixes for 3.13-rc Kishon Vijay Abraham I
2013-12-06 12:21 ` Kishon Vijay Abraham I [this message]
2013-12-06 12:21 ` [PATCH 2/3] drivers: phy: tweaks to phy_create() Kishon Vijay Abraham I
2013-12-06 12:21 ` [PATCH 3/3] phy: kconfig: add depends on "USB_PHY" to OMAP_USB2 and TWL4030_USB Kishon Vijay Abraham I
2013-12-10 20:55 ` [PATCH 0/3] PHY: Fixes for 3.13-rc Greg KH
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=1386332480-31671-2-git-send-email-kishon@ti.com \
--to=kishon@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sachin.kamat@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®