* [PATCH] spi: gpio: prevent memroy leak in spi_gpio_probe
@ 2019-09-30 3:39 Navid Emamdoost
2019-09-30 6:24 ` [PATCH] spi: gpio: prevent memory " Markus Elfring
0 siblings, 1 reply; 8+ messages in thread
From: Navid Emamdoost @ 2019-09-30 3:39 UTC (permalink / raw)
Cc: emamd001, kjlu, smccaman, Navid Emamdoost, Mark Brown, linux-spi,
linux-kernel
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. This commit adds Fixes: spi_contriller_put 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>
---
drivers/spi/spi-gpio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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);
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] spi: gpio: prevent memory leak in spi_gpio_probe
2019-09-30 3:39 [PATCH] spi: gpio: prevent memroy leak in spi_gpio_probe Navid Emamdoost
@ 2019-09-30 6:24 ` Markus Elfring
2019-09-30 20:52 ` [PATCH v2] " Navid Emamdoost
2019-09-30 20:54 ` [PATCH] spi: gpio: prevent memory leak in spi_gpio_probe Navid Emamdoost
0 siblings, 2 replies; 8+ messages in thread
From: Markus Elfring @ 2019-09-30 6:24 UTC (permalink / raw)
To: Navid Emamdoost, linux-spi
Cc: Navid Emamdoost, Kangjie Lu, Stephen McCamant, Mark Brown,
linux-kernel, kernel-janitors
* Please avoid typos in the commit message.
* I would prefer an other wording for the change description.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=97f9a3c4eee55b0178b518ae7114a6a53372913d#n151
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] spi: gpio: prevent memory leak in spi_gpio_probe
2019-09-30 6:24 ` [PATCH] spi: gpio: prevent memory " Markus Elfring
@ 2019-09-30 20:52 ` Navid Emamdoost
2019-10-01 9:11 ` Markus Elfring
2019-10-01 17:57 ` Applied "spi: gpio: prevent memory leak in spi_gpio_probe" to the spi tree Mark Brown
2019-09-30 20:54 ` [PATCH] spi: gpio: prevent memory leak in spi_gpio_probe Navid Emamdoost
1 sibling, 2 replies; 8+ messages in thread
From: Navid Emamdoost @ 2019-09-30 20:52 UTC (permalink / raw)
Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Mark Brown, linux-spi,
linux-kernel
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>
---
Changes in v2:
-- fix a typo in title and update the description
---
drivers/spi/spi-gpio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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);
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] spi: gpio: prevent memory leak in spi_gpio_probe
2019-09-30 6:24 ` [PATCH] spi: gpio: prevent memory " Markus Elfring
2019-09-30 20:52 ` [PATCH v2] " Navid Emamdoost
@ 2019-09-30 20:54 ` Navid Emamdoost
1 sibling, 0 replies; 8+ messages in thread
From: Navid Emamdoost @ 2019-09-30 20:54 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-spi, Navid Emamdoost, Kangjie Lu, Stephen McCamant,
Mark Brown, linux-kernel, kernel-janitors
Fixed the issues in v2.
Thanks,
Navid.
On Mon, Sep 30, 2019 at 1:24 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> * Please avoid typos in the commit message.
>
> * I would prefer an other wording for the change description.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=97f9a3c4eee55b0178b518ae7114a6a53372913d#n151
>
>
> Regards,
> Markus
--
Navid.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] spi: gpio: prevent memory leak in spi_gpio_probe
2019-09-30 20:52 ` [PATCH v2] " Navid Emamdoost
@ 2019-10-01 9:11 ` Markus Elfring
2019-10-01 17:32 ` Navid Emamdoost
2019-10-01 17:57 ` Applied "spi: gpio: prevent memory leak in spi_gpio_probe" to the spi tree Mark Brown
1 sibling, 1 reply; 8+ messages in thread
From: Markus Elfring @ 2019-10-01 9:11 UTC (permalink / raw)
To: Navid Emamdoost, linux-spi
Cc: Navid Emamdoost, Kangjie Lu, Stephen McCamant, Mark Brown,
linux-kernel, kernel-janitors
> … In order to avoid leak spi_contriller_put must
> be called in case of failure for devm_add_action_or_reset.
How does this wording fit to the diff display that you would like
to add the function call “spi_master_put(master)” in
one if branch?
> Fixes: 8b797490b4db ("spi: gpio: Make sure spi_master_put() is called in every error path")
Is there a need to complete the corresponding exception handling
at any more source code places?
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] spi: gpio: prevent memory leak in spi_gpio_probe
2019-10-01 9:11 ` Markus Elfring
@ 2019-10-01 17:32 ` Navid Emamdoost
2019-10-02 5:07 ` [v2] " Markus Elfring
0 siblings, 1 reply; 8+ messages in thread
From: Navid Emamdoost @ 2019-10-01 17:32 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-spi, Navid Emamdoost, Kangjie Lu, Stephen McCamant,
Mark Brown, LKML, kernel-janitors
Hi Markus, thanks for your suggestions for improving the quality of
the patch. At the moment I prefer first get a confirmation from
contributors about the leak and then work on any possible improvements
for the patch.
Thanks,
Navid.
On Tue, Oct 1, 2019 at 4:11 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> > … In order to avoid leak spi_contriller_put must
> > be called in case of failure for devm_add_action_or_reset.
>
> How does this wording fit to the diff display that you would like
> to add the function call “spi_master_put(master)” in
> one if branch?
>
>
> > Fixes: 8b797490b4db ("spi: gpio: Make sure spi_master_put() is called in every error path")
>
> Is there a need to complete the corresponding exception handling
> at any more source code places?
>
> Regards,
> Markus
--
Navid.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Applied "spi: gpio: prevent memory leak in spi_gpio_probe" to the spi tree
2019-09-30 20:52 ` [PATCH v2] " Navid Emamdoost
2019-10-01 9:11 ` Markus Elfring
@ 2019-10-01 17:57 ` Mark Brown
1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2019-10-01 17:57 UTC (permalink / raw)
To: Navid Emamdoost
Cc: Cc:, Cc:, emamd001, kjlu, linux-kernel, linux-spi, Mark Brown, smccaman
The patch
spi: gpio: prevent memory leak in spi_gpio_probe
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.4
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
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: [PATCH] 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(-)
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);
--
2.20.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [v2] spi: gpio: prevent memory leak in spi_gpio_probe
2019-10-01 17:32 ` Navid Emamdoost
@ 2019-10-02 5:07 ` Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2019-10-02 5:07 UTC (permalink / raw)
To: Navid Emamdoost, linux-spi
Cc: Navid Emamdoost, Kangjie Lu, Stephen McCamant, Mark Brown, LKML,
kernel-janitors
> Hi Markus, thanks for your suggestions for improving the quality of
> the patch. At the moment I prefer first get a confirmation from
> contributors about the leak and then work on any possible improvements
> for the patch.
Please fix this patch as soon as possible if you care for the correctness
of the provided information.
Regards,
Markus
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-10-02 5:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30 3:39 [PATCH] spi: gpio: prevent memroy leak in spi_gpio_probe Navid Emamdoost
2019-09-30 6:24 ` [PATCH] spi: gpio: prevent memory " Markus Elfring
2019-09-30 20:52 ` [PATCH v2] " Navid Emamdoost
2019-10-01 9:11 ` Markus Elfring
2019-10-01 17:32 ` Navid Emamdoost
2019-10-02 5:07 ` [v2] " Markus Elfring
2019-10-01 17:57 ` Applied "spi: gpio: prevent memory leak in spi_gpio_probe" to the spi tree Mark Brown
2019-09-30 20:54 ` [PATCH] spi: gpio: prevent memory leak in spi_gpio_probe Navid Emamdoost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).