Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: release device claimed by bus_find_device_by_name

In success case the function bus_find_device_by_name calls
get_device. In our context put_device should be called to
decrease the device count usage.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

authored by

Roman Tereshonkov and committed by
Grant Likely
8ec130a0 9bd73715

+4 -2
+4 -2
drivers/spi/spi.c
··· 257 257 { 258 258 static DEFINE_MUTEX(spi_add_lock); 259 259 struct device *dev = spi->master->dev.parent; 260 + struct device *d; 260 261 int status; 261 262 262 263 /* Chipselects are numbered 0..max; validate. */ ··· 279 278 */ 280 279 mutex_lock(&spi_add_lock); 281 280 282 - if (bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev)) 283 - != NULL) { 281 + d = bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev)); 282 + if (d != NULL) { 284 283 dev_err(dev, "chipselect %d already in use\n", 285 284 spi->chip_select); 285 + put_device(d); 286 286 status = -EBUSY; 287 287 goto done; 288 288 }