diff mbox series

[-next] spi: spi-amd: Remove spi_master_put in amd_spi_remove()

Message ID 20200507115550.139457-1-weiyongjun1@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] spi: spi-amd: Remove spi_master_put in amd_spi_remove() | expand

Commit Message

Wei Yongjun May 7, 2020, 11:55 a.m. UTC
The call to spi_master_put() in amd_spi_remove() is redundant and
may causes user after free since the master have been freed by
spi_unregister_master(), so remove it.

Fixes: bbb336f39efc ("spi: spi-amd: Add AMD SPI controller driver support")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/spi/spi-amd.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Mark Brown May 8, 2020, 5:14 p.m. UTC | #1
On Thu, 7 May 2020 11:55:50 +0000, Wei Yongjun wrote:
> The call to spi_master_put() in amd_spi_remove() is redundant and
> may causes user after free since the master have been freed by
> spi_unregister_master(), so remove it.

Applied to

   local tree regulator/for-5.7

Thanks!

[1/1] spi: spi-amd: Remove spi_master_put in amd_spi_remove()
      (no commit info)

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
Mark Brown May 8, 2020, 5:53 p.m. UTC | #2
On Thu, May 07, 2020 at 11:55:50AM +0000, Wei Yongjun wrote:
> The call to spi_master_put() in amd_spi_remove() is redundant and
> may causes user after free since the master have been freed by
> spi_unregister_master(), so remove it.

This doesn't apply against current code, please check and resend (there
were quite a few issues that got fixed).
Mark Brown May 11, 2020, 5:21 p.m. UTC | #3
On Thu, 7 May 2020 11:55:50 +0000, Wei Yongjun wrote:
> The call to spi_master_put() in amd_spi_remove() is redundant and
> may causes user after free since the master have been freed by
> spi_unregister_master(), so remove it.

Applied to

   local tree spi/for-5.7

Thanks!

[1/1] spi: spi-amd: Remove spi_master_put in amd_spi_remove()
      (no commit info)

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
Mark Brown May 11, 2020, 5:29 p.m. UTC | #4
On Mon, May 11, 2020 at 06:22:01PM +0100, Mark Brown wrote:
> On Thu, 7 May 2020 11:55:50 +0000, Wei Yongjun wrote:
> > The call to spi_master_put() in amd_spi_remove() is redundant and
> > may causes user after free since the master have been freed by
> > spi_unregister_master(), so remove it.
> 
> Applied to
> 
>    local tree spi/for-5.7

No it wasn't, sorry for the noise here.
Wei Yongjun May 12, 2020, 1:22 a.m. UTC | #5
On 2020/5/12 1:29, Mark Brown wrote:
> On Mon, May 11, 2020 at 06:22:01PM +0100, Mark Brown wrote:
>> On Thu, 7 May 2020 11:55:50 +0000, Wei Yongjun wrote:
>>> The call to spi_master_put() in amd_spi_remove() is redundant and
>>> may causes user after free since the master have been freed by
>>> spi_unregister_master(), so remove it.
>>
>> Applied to
>>
>>    local tree spi/for-5.7
> 
> No it wasn't, sorry for the noise here.
> 

I saw similar patch has been merged, so we do not need this patch any more.

7b9c94bd13cc ("spi: amd: Fix refcount underflow on remove")

Links:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=7b9c94bd13cc9dc9c0c4932ebacf756ae612d52a

Regards,
Wei Yongjun
diff mbox series

Patch

diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c
index c7cfc3dc20b1..e5e767ba5823 100644
--- a/drivers/spi/spi-amd.c
+++ b/drivers/spi/spi-amd.c
@@ -304,7 +304,6 @@  static int amd_spi_remove(struct platform_device *pdev)
 	struct amd_spi *amd_spi = platform_get_drvdata(pdev);
 
 	spi_unregister_master(amd_spi->master);
-	spi_master_put(amd_spi->master);
 	platform_set_drvdata(pdev, NULL);
 
 	return 0;