From: Hans-Christian Egtvedt Date: Thu, 7 Dec 2006 04:36:17 +0000 (-0800) Subject: [PATCH] spi: correct bus_num and buffer bug in spi core X-Git-Tag: MMI-PSA29.97-13-9~45878^2~14^2~218 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4740d387f3cb9e63f48f2488815b38a2c92755c8;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git [PATCH] spi: correct bus_num and buffer bug in spi core Correct the following in driver/spi/spi.c in function spi_busnum_to_master: * must allow bus_num 0, the if is really not needed. * correct the name buffer which is too small for bus_num >= 10000. It should be 9 bytes big, not 8. Signed-off-by: Hans-Christian Egtvedt Cc: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 1a3c963dc48a..7d215eaa1370 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -465,15 +465,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master); */ struct spi_master *spi_busnum_to_master(u16 bus_num) { - if (bus_num) { - char name[8]; - struct kobject *bus; - - snprintf(name, sizeof name, "spi%u", bus_num); - bus = kset_find_obj(&spi_master_class.subsys.kset, name); - if (bus) - return container_of(bus, struct spi_master, cdev.kobj); - } + char name[9]; + struct kobject *bus; + + snprintf(name, sizeof name, "spi%u", bus_num); + bus = kset_find_obj(&spi_master_class.subsys.kset, name); + if (bus) + return container_of(bus, struct spi_master, cdev.kobj); return NULL; } EXPORT_SYMBOL_GPL(spi_busnum_to_master);