summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2018-04-26 09:31:52 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-16 10:05:18 +0200
commitee395008270fc9afccbfd32eb8498136a8798c09 (patch)
tree0565f6b6aadaa1f89743f8d3eb268fac98f6de04
parenta24bce47bdc4c5490cc981990bd74e2ba63071f8 (diff)
downloadlinux-stable-ee395008270fc9afccbfd32eb8498136a8798c09.tar.gz
linux-stable-ee395008270fc9afccbfd32eb8498136a8798c09.tar.bz2
linux-stable-ee395008270fc9afccbfd32eb8498136a8798c09.zip
rfkill: gpio: fix memory leak in probe error path
commit 4bf01ca21e2e0e4561d1a03c48c3d740418702db upstream. 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> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 0f62326c0f5e..ffa7a20e7b02 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -134,13 +134,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)