spi: cadence-quadspi: Remove spi_master_put() in probe failure path
authorVaishnav Achath <vaishnav.a@ti.com>
Wed, 1 Jun 2022 07:16:11 +0000 (12:46 +0530)
committerMark Brown <broonie@kernel.org>
Mon, 6 Jun 2022 11:39:18 +0000 (12:39 +0100)
commit8523c96894e916b20ba3612e48e404fad5acfdd9
tree0bedb7aeaf2e8e151f43c78b9c78511098d3e936
parentf52b03c707444c5a3d1a0b9c5724f93ddc3c588e
spi: cadence-quadspi: Remove spi_master_put() in probe failure path

Currently the spi_master is allocated by devm_spi_alloc_master()
and devres core manages the deallocation, but in probe failure
path spi_master_put() is being handled manually which causes
"refcount underflow use-after-free" warning when probe failure happens
after allocating spi_master.

Trimmed backtrace during failure:

refcount_t: underflow; use-after-free.
pc : refcount_warn_saturate+0xf4/0x144
Call trace:
refcount_warn_saturate
kobject_put
put_device
devm_spi_release_controller
devres_release_all

This commit makes relevant changes to remove spi_master_put() from probe
failure path.

Fixes: 606e5d408184 ("spi: cadence-quadspi: Handle spi_unregister_master() in remove()")

Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
Link: https://lore.kernel.org/r/20220601071611.11853-1-vaishnav.a@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-cadence-quadspi.c