diff options
author | Johan Hovold <johan@kernel.org> | 2018-04-26 03:31:52 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2018-05-07 09:01:40 -0400 |
commit | 4bf01ca21e2e0e4561d1a03c48c3d740418702db (patch) | |
tree | b243a583f6261adff678a69d677e942704436d45 | |
parent | e8f90c74e6ab64824f3a21521640de7b21050b9d (diff) |
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 <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>
-rw-r--r-- | net/rfkill/rfkill-gpio.c | 7 |
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) | |||
137 | 137 | ||
138 | ret = rfkill_register(rfkill->rfkill_dev); | 138 | ret = rfkill_register(rfkill->rfkill_dev); |
139 | if (ret < 0) | 139 | if (ret < 0) |
140 | return ret; | 140 | goto err_destroy; |
141 | 141 | ||
142 | platform_set_drvdata(pdev, rfkill); | 142 | platform_set_drvdata(pdev, rfkill); |
143 | 143 | ||
144 | dev_info(&pdev->dev, "%s device registered.\n", rfkill->name); | 144 | dev_info(&pdev->dev, "%s device registered.\n", rfkill->name); |
145 | 145 | ||
146 | return 0; | 146 | return 0; |
147 | |||
148 | err_destroy: | ||
149 | rfkill_destroy(rfkill->rfkill_dev); | ||
150 | |||
151 | return ret; | ||
147 | } | 152 | } |
148 | 153 | ||
149 | static int rfkill_gpio_remove(struct platform_device *pdev) | 154 | static int rfkill_gpio_remove(struct platform_device *pdev) |