diff options
author | Lukas Wunner <lukas@wunner.de> | 2020-05-04 13:12:04 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-05-04 17:18:48 +0100 |
commit | 7b9c94bd13cc9dc9c0c4932ebacf756ae612d52a (patch) | |
tree | acc416a8a3680e6f59ee7603e1c26c8cdaef9d87 | |
parent | 4332ea8f40c80d51a534f194291bf3b7738a7beb (diff) |
spi: amd: Fix refcount underflow on remove
The AMD SPI driver calls spi_master_put() in its ->remove() hook even
though the preceding call to spi_unregister_master() already drops a
ref, thus leading to a refcount underflow. Drop the superfluous call
to spi_master_put().
This only leaves the call to spi_unregister_master() in the ->remove()
hook, so it's safe to change the ->probe() hook to use the devm version
of spi_register_master() and drop the ->remove() hook altogether.
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Link: https://lore.kernel.org/r/5e53ccdf1eecd4e015dba99d0d77389107f8a2e3.1588590210.git.lukas@wunner.de
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/spi/spi-amd.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c index d3e3516ef957..00f2f3405e08 100644 --- a/drivers/spi/spi-amd.c +++ b/drivers/spi/spi-amd.c @@ -282,7 +282,7 @@ static int amd_spi_probe(struct platform_device *pdev) master->transfer_one_message = amd_spi_master_transfer; /* Register the controller with SPI framework */ - err = spi_register_master(master); + err = devm_spi_register_master(dev, master); if (err) { dev_err(dev, "error %d registering SPI controller\n", err); goto err_free_master; @@ -296,16 +296,6 @@ err_free_master: return err; } -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); - - return 0; -} - static const struct acpi_device_id spi_acpi_match[] = { { "AMDI0061", 0 }, {}, @@ -318,7 +308,6 @@ static struct platform_driver amd_spi_driver = { .acpi_match_table = ACPI_PTR(spi_acpi_match), }, .probe = amd_spi_probe, - .remove = amd_spi_remove, }; module_platform_driver(amd_spi_driver); |