提交 93964fd4 编写于 作者: J James Bottomley 提交者: Helge Deller

parisc: pdc_stable: Fix locking when creating sysfs links

There's no need to take the write lock when creating sysfs links.

This patch fixes the following BUG:
 BUG: sleeping function called from invalid context at mm/slab.h:416
 in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: swapper/0
 CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.13.0-rc2-00110-g0b5477d9 #111
 Backtrace:
 [<0000000040217ac8>] show_stack+0x20/0x38
 [<00000000406fbbb0>] dump_stack+0xb0/0x128
 [<0000000040274090>] ___might_sleep+0x180/0x1b8
 [<0000000040274144>] __might_sleep+0x7c/0xe8
 [<0000000040373874>] kmem_cache_alloc+0x14c/0x1e0
 [<0000000040419514>] __kernfs_new_node+0x84/0x1b8
 [<000000004041b09c>] kernfs_new_node+0x3c/0x78
 [<000000004041e040>] kernfs_create_link+0x40/0xd8
 [<000000004041f320>] sysfs_do_create_link_sd.isra.0+0xb0/0x130
 [<000000004041f3d4>] sysfs_create_link+0x34/0x58
 [<000000004011b4a4>] pdc_stable_init+0x2c4/0x458
 [<0000000040200250>] do_one_initcall+0x70/0x1d8
 [<0000000040101644>] kernel_init_freeable+0x27c/0x390
 [<000000004020be44>] kernel_init+0x24/0x1c0
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
Reported-by: NMeelis Roos <mroos@linux.ee>
Signed-off-by: NHelge Deller <deller@gmx.de>
上级 8f8201df
...@@ -333,11 +333,11 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t coun ...@@ -333,11 +333,11 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t coun
/* Update the symlink to the real device */ /* Update the symlink to the real device */
sysfs_remove_link(&entry->kobj, "device"); sysfs_remove_link(&entry->kobj, "device");
write_unlock(&entry->rw_lock);
ret = sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device"); ret = sysfs_create_link(&entry->kobj, &entry->dev->kobj, "device");
WARN_ON(ret); WARN_ON(ret);
write_unlock(&entry->rw_lock);
printk(KERN_INFO PDCS_PREFIX ": changed \"%s\" path to \"%s\"\n", printk(KERN_INFO PDCS_PREFIX ": changed \"%s\" path to \"%s\"\n",
entry->name, buf); entry->name, buf);
...@@ -998,6 +998,7 @@ pdcs_register_pathentries(void) ...@@ -998,6 +998,7 @@ pdcs_register_pathentries(void)
/* kobject is now registered */ /* kobject is now registered */
write_lock(&entry->rw_lock); write_lock(&entry->rw_lock);
entry->ready = 2; entry->ready = 2;
write_unlock(&entry->rw_lock);
/* Add a nice symlink to the real device */ /* Add a nice symlink to the real device */
if (entry->dev) { if (entry->dev) {
...@@ -1005,7 +1006,6 @@ pdcs_register_pathentries(void) ...@@ -1005,7 +1006,6 @@ pdcs_register_pathentries(void)
WARN_ON(err); WARN_ON(err);
} }
write_unlock(&entry->rw_lock);
kobject_uevent(&entry->kobj, KOBJ_ADD); kobject_uevent(&entry->kobj, KOBJ_ADD);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册