diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2007-01-26 03:56:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-01-26 16:50:58 -0500 |
commit | 1e9a51dca19dc1d8807c63cb3bd4413d3f95aaf5 (patch) | |
tree | 941d5039c0dfb5aeb8a499e9cbebda0a1e80d8a8 /drivers | |
parent | 863c47028eb469c9e6c4e4287b01bea2bbf78766 (diff) |
[PATCH] SPI: alternative fix for spi_busnum_to_master
If a SPI master device exists, udev (udevtrigger) causes kernel crash, due
to wrong kobj pointer in kobject_uevent_env(). This problem was not in
2.6.19.
The backtrace (on MIPS) was:
[<8024db6c>] kobject_uevent_env+0x54c/0x5e8
[<802a8264>] store_uevent+0x1c/0x3c (in drivers/class.c)
[<801cb14c>] subsys_attr_store+0x2c/0x50
[<801cb80c>] flush_write_buffer+0x38/0x5c
[<801cb900>] sysfs_write_file+0xd0/0x190
[<80181444>] vfs_write+0xc4/0x1a0
[<80181cdc>] sys_write+0x54/0xa0
[<8010dae4>] stack_done+0x20/0x3c
flush_write_buffer() passes kobject of spi_master_class.subsys to
subsys_addr_store(), then subsys_addr_store() passes a pointer to a struct
subsystem to store_uevent() which expects a pointer to a struct
class_device. The problem seems subsys_attr_store() called instead of
class_device_attr_store().
This mismatch was caused by commit
3bd0f6943520e459659d10f3282285e43d3990f1, which overrides kset of master
class. This made spi_master_class.subsys.kset.ktype NULL so
subsys_sysfs_ops is used instead of class_dev_sysfs_ops.
The commit was to fix spi_busnum_to_master(). Here is a patch fixes
this function in other way, just searching children list of
class_device.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/spi.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 270e6211c2e3..6307428d2c94 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -366,7 +366,6 @@ spi_alloc_master(struct device *dev, unsigned size) | |||
366 | 366 | ||
367 | class_device_initialize(&master->cdev); | 367 | class_device_initialize(&master->cdev); |
368 | master->cdev.class = &spi_master_class; | 368 | master->cdev.class = &spi_master_class; |
369 | kobj_set_kset_s(&master->cdev, spi_master_class.subsys); | ||
370 | master->cdev.dev = get_device(dev); | 369 | master->cdev.dev = get_device(dev); |
371 | spi_master_set_devdata(master, &master[1]); | 370 | spi_master_set_devdata(master, &master[1]); |
372 | 371 | ||
@@ -466,14 +465,20 @@ EXPORT_SYMBOL_GPL(spi_unregister_master); | |||
466 | */ | 465 | */ |
467 | struct spi_master *spi_busnum_to_master(u16 bus_num) | 466 | struct spi_master *spi_busnum_to_master(u16 bus_num) |
468 | { | 467 | { |
469 | char name[9]; | 468 | struct class_device *cdev; |
470 | struct kobject *bus; | 469 | struct spi_master *master = NULL; |
471 | 470 | struct spi_master *m; | |
472 | snprintf(name, sizeof name, "spi%u", bus_num); | 471 | |
473 | bus = kset_find_obj(&spi_master_class.subsys.kset, name); | 472 | down(&spi_master_class.sem); |
474 | if (bus) | 473 | list_for_each_entry(cdev, &spi_master_class.children, node) { |
475 | return container_of(bus, struct spi_master, cdev.kobj); | 474 | m = container_of(cdev, struct spi_master, cdev); |
476 | return NULL; | 475 | if (m->bus_num == bus_num) { |
476 | master = spi_master_get(m); | ||
477 | break; | ||
478 | } | ||
479 | } | ||
480 | up(&spi_master_class.sem); | ||
481 | return master; | ||
477 | } | 482 | } |
478 | EXPORT_SYMBOL_GPL(spi_busnum_to_master); | 483 | EXPORT_SYMBOL_GPL(spi_busnum_to_master); |
479 | 484 | ||