* [PATCH] net: rfkill: gpio: fix memory leak in probe error path
@ 2018-04-26 7:31 Johan Hovold
2018-04-26 8:14 ` Heikki Krogerus
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2018-04-26 7:31 UTC (permalink / raw)
To: Johannes Berg
Cc: David S. Miller, linux-wireless, netdev, linux-kernel,
Johan Hovold, stable, Heikki Krogerus
Make sure to free the rfkill device in case registration fails during
probe.
Fixes: 5e7ca3937fbe ("net: rfkill: gpio: convert to resource managed allocation")
Cc: stable <stable@vger.kernel.org> # 3.13
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
net/rfkill/rfkill-gpio.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index 41bd496531d4..00192a996be0 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -137,13 +137,18 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
ret = rfkill_register(rfkill->rfkill_dev);
if (ret < 0)
- return ret;
+ goto err_destroy;
platform_set_drvdata(pdev, rfkill);
dev_info(&pdev->dev, "%s device registered.\n", rfkill->name);
return 0;
+
+err_destroy:
+ rfkill_destroy(rfkill->rfkill_dev);
+
+ return ret;
}
static int rfkill_gpio_remove(struct platform_device *pdev)
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: rfkill: gpio: fix memory leak in probe error path
2018-04-26 7:31 [PATCH] net: rfkill: gpio: fix memory leak in probe error path Johan Hovold
@ 2018-04-26 8:14 ` Heikki Krogerus
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2018-04-26 8:14 UTC (permalink / raw)
To: Johan Hovold
Cc: Johannes Berg, David S. Miller, linux-wireless, netdev,
linux-kernel, stable
On Thu, Apr 26, 2018 at 09:31:52AM +0200, Johan Hovold wrote:
> Make sure to free the rfkill device in case registration fails during
> probe.
>
> Fixes: 5e7ca3937fbe ("net: rfkill: gpio: convert to resource managed allocation")
> Cc: stable <stable@vger.kernel.org> # 3.13
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Good catch. FWIW:
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> net/rfkill/rfkill-gpio.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
> index 41bd496531d4..00192a996be0 100644
> --- a/net/rfkill/rfkill-gpio.c
> +++ b/net/rfkill/rfkill-gpio.c
> @@ -137,13 +137,18 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
>
> ret = rfkill_register(rfkill->rfkill_dev);
> if (ret < 0)
> - return ret;
> + goto err_destroy;
>
> platform_set_drvdata(pdev, rfkill);
>
> dev_info(&pdev->dev, "%s device registered.\n", rfkill->name);
>
> return 0;
> +
> +err_destroy:
> + rfkill_destroy(rfkill->rfkill_dev);
> +
> + return ret;
> }
>
> static int rfkill_gpio_remove(struct platform_device *pdev)
> --
> 2.17.0
--
heikki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-26 8:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26 7:31 [PATCH] net: rfkill: gpio: fix memory leak in probe error path Johan Hovold
2018-04-26 8:14 ` Heikki Krogerus
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.