All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drivers: phy: Fix memory leak
@ 2013-10-25  5:26 Sachin Kamat
  2013-10-31  8:46 ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 3+ messages in thread
From: Sachin Kamat @ 2013-10-25  5:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: kishon, sachin.kamat

'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>
---
 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.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] drivers: phy: Fix memory leak
  2013-10-25  5:26 [PATCH 1/1] drivers: phy: Fix memory leak Sachin Kamat
@ 2013-10-31  8:46 ` Kishon Vijay Abraham I
  2013-10-31  8:49   ` Sachin Kamat
  0 siblings, 1 reply; 3+ messages in thread
From: Kishon Vijay Abraham I @ 2013-10-31  8:46 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-kernel

Hi,

On Friday 25 October 2013 10:56 AM, Sachin Kamat wrote:
> 'phy' was not being freed upon error in one of the cases.
> Adjust the 'goto's to fix this.

This patch looks good. I'll send this once -rc1 is tagged?

Thanks
Kishon
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  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);
>  }
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] drivers: phy: Fix memory leak
  2013-10-31  8:46 ` Kishon Vijay Abraham I
@ 2013-10-31  8:49   ` Sachin Kamat
  0 siblings, 0 replies; 3+ messages in thread
From: Sachin Kamat @ 2013-10-31  8:49 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: LKML

On 31 October 2013 14:16, Kishon Vijay Abraham I <kishon@ti.com> wrote:
> Hi,
>
> On Friday 25 October 2013 10:56 AM, Sachin Kamat wrote:
>> 'phy' was not being freed upon error in one of the cases.
>> Adjust the 'goto's to fix this.
>
> This patch looks good. I'll send this once -rc1 is tagged?

Sure. Thanks.

-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-31  8:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-25  5:26 [PATCH 1/1] drivers: phy: Fix memory leak Sachin Kamat
2013-10-31  8:46 ` Kishon Vijay Abraham I
2013-10-31  8:49   ` Sachin Kamat

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.