spi: core: invert success test in devm_spi_register_master
authorStephen Warren <swarren@nvidia.com>
Thu, 21 Nov 2013 23:11:15 +0000 (16:11 -0700)
committerMark Brown <broonie@linaro.org>
Fri, 22 Nov 2013 00:07:29 +0000 (00:07 +0000)
commit4b92894ee70c9110c083aa60b0663d357495864d
treed60cf2b146efe7c2d9135818fa4188dc42f55563
parent82f85cf98f0eb60093e8b3d606711c2d49538478
spi: core: invert success test in devm_spi_register_master

devres_add() should be called when the action to be undone succeeded,
not when it failed. Fix the inverted test in devm_spi_register_master()
which was doing the opposite.

The user-visible issue without this fix is:
insmod spi-tegra114.ko
  Assume there's an MTD device on that SPI bus, which creates /dev/mtd0.
rmmod spi-tegra114
  Doesn't remove devices on the SPI bus.
insmod spi-tegra114.ko
  Creates a duplicate SPI device which creates /dev/mtd1.
hexdump -C /dev/mtd0
  That's the old device, which uses an SPI bus hosted by a non-existent
  module, which causes the oops below.

Unable to handle kernel paging request at virtual address bf0017c0
pgd = c0004000
[bf0017c0] *pgd=ad51b811, *pte=00000000, *ppte=00000000
Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM
...
PC is at 0xbf0017c0
LR is at spi_pump_messages+0x15c/0x204
pc : [<bf0017c0>] lr : [<c02f0af8>] psr: 60000113
...

Fixes: 666d5b4c742b ("spi: core: Add devm_spi_register_master()")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi.c