aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <[email protected]>2018-04-26 07:31:52 +0000
committerJohannes Berg <[email protected]>2018-05-07 13:01:40 +0000
commit4bf01ca21e2e0e4561d1a03c48c3d740418702db (patch)
treeb243a583f6261adff678a69d677e942704436d45
parentmac80211_hwsim: fix a possible memory leak in hwsim_new_radio_nl() (diff)
downloadkernel-4bf01ca21e2e0e4561d1a03c48c3d740418702db.tar.gz
kernel-4bf01ca21e2e0e4561d1a03c48c3d740418702db.zip
rfkill: gpio: fix memory leak in probe error path
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 <[email protected]> # 3.13 Cc: Heikki Krogerus <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
-rw-r--r--net/rfkill/rfkill-gpio.c7
1 files changed, 6 insertions, 1 deletions
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)