* [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put call
@ 2024-04-03 8:40 carlos.song
2024-04-03 8:51 ` Sverdlin, Alexander
2024-04-03 13:32 ` Mark Brown
0 siblings, 2 replies; 4+ messages in thread
From: carlos.song @ 2024-04-03 8:40 UTC (permalink / raw)
To: broonie, alexander.sverdlin
Cc: linux-spi, linux-kernel, imx, haibo.chen, jun.li, linux-imx
From: Carlos Song <carlos.song@nxp.com>
devm_spi_alloc_controller will allocate an SPI controller and
automatically release a reference on it when dev is unbound from
its driver. It doesn't need to call spi_controller_put explicitly
to put the reference when lpspi driver failed initialization.
Fixes: 2ae0ab0143fc ("spi: lpspi: Avoid potential use-after-free in probe()")
Signed-off-by: Carlos Song <carlos.song@nxp.com>
---
drivers/spi/spi-fsl-lpspi.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 079035db7dd8..92a662d1b55c 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -852,39 +852,39 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
fsl_lpspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(fsl_lpspi->base)) {
ret = PTR_ERR(fsl_lpspi->base);
- goto out_controller_put;
+ return ret;
}
fsl_lpspi->base_phys = res->start;
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
ret = irq;
- goto out_controller_put;
+ return ret;
}
ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, 0,
dev_name(&pdev->dev), fsl_lpspi);
if (ret) {
dev_err(&pdev->dev, "can't get irq%d: %d\n", irq, ret);
- goto out_controller_put;
+ return ret;
}
fsl_lpspi->clk_per = devm_clk_get(&pdev->dev, "per");
if (IS_ERR(fsl_lpspi->clk_per)) {
ret = PTR_ERR(fsl_lpspi->clk_per);
- goto out_controller_put;
+ return ret;
}
fsl_lpspi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
if (IS_ERR(fsl_lpspi->clk_ipg)) {
ret = PTR_ERR(fsl_lpspi->clk_ipg);
- goto out_controller_put;
+ return ret;
}
/* enable the clock */
ret = fsl_lpspi_init_rpm(fsl_lpspi);
if (ret)
- goto out_controller_put;
+ return ret;
ret = pm_runtime_get_sync(fsl_lpspi->dev);
if (ret < 0) {
@@ -945,8 +945,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
pm_runtime_dont_use_autosuspend(fsl_lpspi->dev);
pm_runtime_put_sync(fsl_lpspi->dev);
pm_runtime_disable(fsl_lpspi->dev);
-out_controller_put:
- spi_controller_put(controller);
return ret;
}
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put call
2024-04-03 8:40 [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put call carlos.song
@ 2024-04-03 8:51 ` Sverdlin, Alexander
2024-04-03 10:09 ` Carlos Song
2024-04-03 13:32 ` Mark Brown
1 sibling, 1 reply; 4+ messages in thread
From: Sverdlin, Alexander @ 2024-04-03 8:51 UTC (permalink / raw)
To: broonie, carlos.song
Cc: linux-spi, imx, haibo.chen, linux-kernel, linux-imx, jun.li
Hi Carlos!
On Wed, 2024-04-03 at 16:40 +0800, carlos.song@nxp.com wrote:
> devm_spi_alloc_controller will allocate an SPI controller and
> automatically release a reference on it when dev is unbound from
> its driver. It doesn't need to call spi_controller_put explicitly
> to put the reference when lpspi driver failed initialization.
>
> Fixes: 2ae0ab0143fc ("spi: lpspi: Avoid potential use-after-free in probe()")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
You are absolutely right!
Sorry for the stupid mistake and thanks for the patch!
Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> ---
> drivers/spi/spi-fsl-lpspi.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
> index 079035db7dd8..92a662d1b55c 100644
> --- a/drivers/spi/spi-fsl-lpspi.c
> +++ b/drivers/spi/spi-fsl-lpspi.c
> @@ -852,39 +852,39 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
> fsl_lpspi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> if (IS_ERR(fsl_lpspi->base)) {
> ret = PTR_ERR(fsl_lpspi->base);
> - goto out_controller_put;
> + return ret;
> }
> fsl_lpspi->base_phys = res->start;
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0) {
> ret = irq;
> - goto out_controller_put;
> + return ret;
> }
>
> ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, 0,
> dev_name(&pdev->dev), fsl_lpspi);
> if (ret) {
> dev_err(&pdev->dev, "can't get irq%d: %d\n", irq, ret);
> - goto out_controller_put;
> + return ret;
> }
>
> fsl_lpspi->clk_per = devm_clk_get(&pdev->dev, "per");
> if (IS_ERR(fsl_lpspi->clk_per)) {
> ret = PTR_ERR(fsl_lpspi->clk_per);
> - goto out_controller_put;
> + return ret;
> }
>
> fsl_lpspi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
> if (IS_ERR(fsl_lpspi->clk_ipg)) {
> ret = PTR_ERR(fsl_lpspi->clk_ipg);
> - goto out_controller_put;
> + return ret;
> }
>
> /* enable the clock */
> ret = fsl_lpspi_init_rpm(fsl_lpspi);
> if (ret)
> - goto out_controller_put;
> + return ret;
>
> ret = pm_runtime_get_sync(fsl_lpspi->dev);
> if (ret < 0) {
> @@ -945,8 +945,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
> pm_runtime_dont_use_autosuspend(fsl_lpspi->dev);
> pm_runtime_put_sync(fsl_lpspi->dev);
> pm_runtime_disable(fsl_lpspi->dev);
> -out_controller_put:
> - spi_controller_put(controller);
>
> return ret;
> }
--
Alexander Sverdlin
Siemens AG
www.siemens.com
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put call
2024-04-03 8:51 ` Sverdlin, Alexander
@ 2024-04-03 10:09 ` Carlos Song
0 siblings, 0 replies; 4+ messages in thread
From: Carlos Song @ 2024-04-03 10:09 UTC (permalink / raw)
To: Sverdlin, Alexander, broonie
Cc: linux-spi, imx, Bough Chen, linux-kernel, dl-linux-imx, Jun Li
> -----Original Message-----
> From: Sverdlin, Alexander <alexander.sverdlin@siemens.com>
> Sent: Wednesday, April 3, 2024 4:51 PM
> To: broonie@kernel.org; Carlos Song <carlos.song@nxp.com>
> Cc: linux-spi@vger.kernel.org; imx@lists.linux.dev; Bough Chen
> <haibo.chen@nxp.com>; linux-kernel@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>; Jun Li <jun.li@nxp.com>
> Subject: [EXT] Re: [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put
> call
>
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report this
> email' button
>
>
> Hi Carlos!
>
> On Wed, 2024-04-03 at 16:40 +0800, carlos.song@nxp.com wrote:
> > devm_spi_alloc_controller will allocate an SPI controller and
> > automatically release a reference on it when dev is unbound from its
> > driver. It doesn't need to call spi_controller_put explicitly to put
> > the reference when lpspi driver failed initialization.
> >
> > Fixes: 2ae0ab0143fc ("spi: lpspi: Avoid potential use-after-free in
> > probe()")
> > Signed-off-by: Carlos Song <carlos.song@nxp.com>
>
> You are absolutely right!
> Sorry for the stupid mistake and thanks for the patch!
>
> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
>
Hi, Alexander
It doesn't matter:)!
Thanks for your such quick ack.
BR
Carlos
> > ---
> > drivers/spi/spi-fsl-lpspi.c | 14 ++++++--------
> > 1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
> > index 079035db7dd8..92a662d1b55c 100644
> > --- a/drivers/spi/spi-fsl-lpspi.c
> > +++ b/drivers/spi/spi-fsl-lpspi.c
> > @@ -852,39 +852,39 @@ static int fsl_lpspi_probe(struct platform_device
> *pdev)
> > fsl_lpspi->base = devm_platform_get_and_ioremap_resource(pdev,
> 0, &res);
> > if (IS_ERR(fsl_lpspi->base)) {
> > ret = PTR_ERR(fsl_lpspi->base);
> > - goto out_controller_put;
> > + return ret;
> > }
> > fsl_lpspi->base_phys = res->start;
> >
> > irq = platform_get_irq(pdev, 0);
> > if (irq < 0) {
> > ret = irq;
> > - goto out_controller_put;
> > + return ret;
> > }
> >
> > ret = devm_request_irq(&pdev->dev, irq, fsl_lpspi_isr, 0,
> > dev_name(&pdev->dev), fsl_lpspi);
> > if (ret) {
> > dev_err(&pdev->dev, "can't get irq%d: %d\n", irq, ret);
> > - goto out_controller_put;
> > + return ret;
> > }
> >
> > fsl_lpspi->clk_per = devm_clk_get(&pdev->dev, "per");
> > if (IS_ERR(fsl_lpspi->clk_per)) {
> > ret = PTR_ERR(fsl_lpspi->clk_per);
> > - goto out_controller_put;
> > + return ret;
> > }
> >
> > fsl_lpspi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
> > if (IS_ERR(fsl_lpspi->clk_ipg)) {
> > ret = PTR_ERR(fsl_lpspi->clk_ipg);
> > - goto out_controller_put;
> > + return ret;
> > }
> >
> > /* enable the clock */
> > ret = fsl_lpspi_init_rpm(fsl_lpspi);
> > if (ret)
> > - goto out_controller_put;
> > + return ret;
> >
> > ret = pm_runtime_get_sync(fsl_lpspi->dev);
> > if (ret < 0) {
> > @@ -945,8 +945,6 @@ static int fsl_lpspi_probe(struct platform_device
> *pdev)
> > pm_runtime_dont_use_autosuspend(fsl_lpspi->dev);
> > pm_runtime_put_sync(fsl_lpspi->dev);
> > pm_runtime_disable(fsl_lpspi->dev);
> > -out_controller_put:
> > - spi_controller_put(controller);
> >
> > return ret;
> > }
>
> --
> Alexander Sverdlin
> Siemens AG
> http://www.siem/
> ens.com%2F&data=05%7C02%7Ccarlos.song%40nxp.com%7C720beaccc4c94dc
> 67f5a08dc53bb3833%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6
> 38477310781786088%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAi
> LCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata
> =%2BLd5E9xU01iVHHQsoJM9zDbNSpn47cjoNC9yf8qCjjI%3D&reserved=0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put call
2024-04-03 8:40 [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put call carlos.song
2024-04-03 8:51 ` Sverdlin, Alexander
@ 2024-04-03 13:32 ` Mark Brown
1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-04-03 13:32 UTC (permalink / raw)
To: alexander.sverdlin, carlos.song
Cc: linux-spi, linux-kernel, imx, haibo.chen, jun.li, linux-imx
On Wed, 03 Apr 2024 16:40:29 +0800, carlos.song@nxp.com wrote:
> devm_spi_alloc_controller will allocate an SPI controller and
> automatically release a reference on it when dev is unbound from
> its driver. It doesn't need to call spi_controller_put explicitly
> to put the reference when lpspi driver failed initialization.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: spi-fsl-lpspi: remove redundant spi_controller_put call
commit: bff892acf79cec531da6cb21c50980a584ce1476
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-03 13:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03 8:40 [PATCH] spi: spi-fsl-lpspi: remove redundant spi_controller_put call carlos.song
2024-04-03 8:51 ` Sverdlin, Alexander
2024-04-03 10:09 ` Carlos Song
2024-04-03 13:32 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®