From: Roger Quadros <rogerq@ti.com>
To: <tony@atomide.com>, <kishon@ti.com>, <balbi@ti.com>
Cc: <nsekhar@ti.com>, <nm@ti.com>, <george.cherian@ti.com>,
<sergei.shtylyov@cogentembedded.com>,
<linux-omap@vger.kernel.org>, <linux-usb@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Roger Quadros <rogerq@ti.com>
Subject: [PATCH v2 2/6] phy: core: Fix error path in phy_create()
Date: Fri, 4 Jul 2014 12:55:44 +0300 [thread overview]
Message-ID: <1404467748-12154-3-git-send-email-rogerq@ti.com> (raw)
In-Reply-To: <1404467748-12154-1-git-send-email-rogerq@ti.com>
Prevent resources from being freed twice in case device_add() call
fails within phy_create(). Also use ida_simple_remove() instead of
ida_remove() as we had used ida_simple_get() to allocate the ida.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
drivers/phy/phy-core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index c64a2f3..49c4465 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -614,8 +614,9 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
return phy;
put_dev:
- put_device(&phy->dev);
- ida_remove(&phy_ida, phy->id);
+ put_device(&phy->dev); /* calls phy_release() which frees resources */
+ return ERR_PTR(ret);
+
free_phy:
kfree(phy);
return ERR_PTR(ret);
@@ -799,7 +800,7 @@ static void phy_release(struct device *dev)
phy = to_phy(dev);
dev_vdbg(dev, "releasing '%s'\n", dev_name(dev));
- ida_remove(&phy_ida, phy->id);
+ ida_simple_remove(&phy_ida, phy->id);
kfree(phy);
}
--
1.8.3.2
next prev parent reply other threads:[~2014-07-04 10:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-04 9:55 [PATCH v2 0/6] omap: phy: dra7-evm PHY fixes for 3.16 Roger Quadros
2014-07-04 9:55 ` [PATCH v2 1/6] ARM: dts: dra7-evm: Make VDDA_1V8_PHY supply always on Roger Quadros
2014-07-07 8:29 ` Tony Lindgren
2014-07-07 8:34 ` Roger Quadros
2014-07-07 8:44 ` Tony Lindgren
2014-07-04 9:55 ` Roger Quadros [this message]
2014-07-04 9:55 ` [PATCH v2 3/6] phy: core: Support regulator supply for PHY power Roger Quadros
2014-07-04 9:55 ` [PATCH v2 4/6] phy: core: Add phy-supply to DT binding documentation Roger Quadros
2014-07-04 9:55 ` [PATCH v2 5/6] phy: omap-usb2: Balance pm_runtime_enable() on probe failure and remove Roger Quadros
2014-07-04 9:55 ` [PATCH v2 6/6] ARM: dts: dra7-evm: Add regulator information to USB2 PHYs Roger Quadros
2014-07-07 8:29 ` Tony Lindgren
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=1404467748-12154-3-git-send-email-rogerq@ti.com \
--to=rogerq@ti.com \
--cc=balbi@ti.com \
--cc=george.cherian@ti.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nm@ti.com \
--cc=nsekhar@ti.com \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=tony@atomide.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
all inboxes | Powered by JetHome®