summaryrefslogtreecommitdiffstats
path: root/spi-gpio-prevent-memory-leak-in-spi_gpio_probe.patch
diff options
context:
space:
mode:
authorJeremy Cline <jcline@redhat.com>2019-12-04 13:38:43 -0500
committerJeremy Cline <jcline@redhat.com>2019-12-04 13:38:43 -0500
commit079e0f545a491903a6acb0dc783d162ae84a2e6c (patch)
tree7a030bec812ab5e3e50079ebf0015ce8504a5b3e /spi-gpio-prevent-memory-leak-in-spi_gpio_probe.patch
parentc1e2dca7bf02f21854445669ab48f82dead65dfc (diff)
downloadkernel-079e0f545a491903a6acb0dc783d162ae84a2e6c.tar.gz
kernel-079e0f545a491903a6acb0dc783d162ae84a2e6c.tar.xz
kernel-079e0f545a491903a6acb0dc783d162ae84a2e6c.zip
Sync up stabilization with f31
Diffstat (limited to 'spi-gpio-prevent-memory-leak-in-spi_gpio_probe.patch')
-rw-r--r--spi-gpio-prevent-memory-leak-in-spi_gpio_probe.patch39
1 files changed, 39 insertions, 0 deletions
diff --git a/spi-gpio-prevent-memory-leak-in-spi_gpio_probe.patch b/spi-gpio-prevent-memory-leak-in-spi_gpio_probe.patch
new file mode 100644
index 000000000..e0a79cfe2
--- /dev/null
+++ b/spi-gpio-prevent-memory-leak-in-spi_gpio_probe.patch
@@ -0,0 +1,39 @@
+From d3b0ffa1d75d5305ebe34735598993afbb8a869d Mon Sep 17 00:00:00 2001
+From: Navid Emamdoost <navid.emamdoost@gmail.com>
+Date: Mon, 30 Sep 2019 15:52:40 -0500
+Subject: spi: gpio: prevent memory leak in spi_gpio_probe
+
+In spi_gpio_probe an SPI master is allocated via spi_alloc_master, but
+this controller should be released if devm_add_action_or_reset fails,
+otherwise memory leaks. In order to avoid leak spi_contriller_put must
+be called in case of failure for devm_add_action_or_reset.
+
+Fixes: 8b797490b4db ("spi: gpio: Make sure spi_master_put() is called in every error path")
+Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
+Link: https://lore.kernel.org/r/20190930205241.5483-1-navid.emamdoost@gmail.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+---
+ drivers/spi/spi-gpio.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+(limited to 'drivers/spi/spi-gpio.c')
+
+diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
+index 1d3e23ec20a6..f9c5bbb74714 100644
+--- a/drivers/spi/spi-gpio.c
++++ b/drivers/spi/spi-gpio.c
+@@ -371,8 +371,10 @@ static int spi_gpio_probe(struct platform_device *pdev)
+ return -ENOMEM;
+
+ status = devm_add_action_or_reset(&pdev->dev, spi_gpio_put, master);
+- if (status)
++ if (status) {
++ spi_master_put(master);
+ return status;
++ }
+
+ if (of_id)
+ status = spi_gpio_probe_dt(pdev, master);
+--
+cgit 1.2-0.3.lf.el7
+