diff options
author | Borislav Petkov <bp@suse.de> | 2015-12-01 09:52:36 -0500 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2015-12-11 10:56:38 -0500 |
commit | 12e26969b32c79018165d52caff3762135614aa1 (patch) | |
tree | 6c8e5fc7a2231acc9c9d47e8e5811aea6100dfd8 | |
parent | 666db563d3d9fffcfc019e3d1a980dac47601a71 (diff) |
EDAC, mc_sysfs: Fix freeing bus' name
I get the splat below when modprobing/rmmoding EDAC drivers. It happens
because bus->name is invalid after bus_unregister() has run. The Code: section
below corresponds to:
.loc 1 1108 0
movq 672(%rbx), %rax # mci_1(D)->bus, mci_1(D)->bus
.loc 1 1109 0
popq %rbx #
.loc 1 1108 0
movq (%rax), %rdi # _7->name,
jmp kfree #
and %rax has some funky stuff 2030203020312030 which looks a lot like
something walked over it.
Fix that by saving the name ptr before doing stuff to string it points to.
general protection fault: 0000 [#1] SMP
Modules linked in: ...
CPU: 4 PID: 10318 Comm: modprobe Tainted: G I EN 3.12.51-11-default+ #48
Hardware name: HP ProLiant DL380 G7, BIOS P67 05/05/2011
task: ffff880311320280 ti: ffff88030da3e000 task.ti: ffff88030da3e000
RIP: 0010:[<ffffffffa019da92>] [<ffffffffa019da92>] edac_unregister_sysfs+0x22/0x30 [edac_core]
RSP: 0018:ffff88030da3fe28 EFLAGS: 00010292
RAX: 2030203020312030 RBX: ffff880311b4e000 RCX: 000000000000095c
RDX: 0000000000000001 RSI: ffff880327bb9600 RDI: 0000000000000286
RBP: ffff880311b4e750 R08: 0000000000000000 R09: ffffffff81296110
R10: 0000000000000400 R11: 0000000000000000 R12: ffff88030ba1ac68
R13: 0000000000000001 R14: 00000000011b02f0 R15: 0000000000000000
FS: 00007fc9bf8f5700(0000) GS:ffff8801a7c40000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000403c90 CR3: 000000019ebdf000 CR4: 00000000000007e0
Stack:
Call Trace:
i7core_unregister_mci.isra.9
i7core_remove
pci_device_remove
__device_release_driver
driver_detach
bus_remove_driver
pci_unregister_driver
i7core_exit
SyS_delete_module
system_call_fastpath
0x7fc9bf426536
Code: 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90 53 48 89 fb e8 52 2a 1f e1 48 8b bb a0 02 00 00 e8 46 59 1f e1 48 8b 83 a0 02 00 00 5b <48> 8b 38 e9 26 9a fe e0 66 0f 1f 44 00 00 66 66 66 66 90 48 8b
RIP [<ffffffffa019da92>] edac_unregister_sysfs+0x22/0x30 [edac_core]
RSP <ffff88030da3fe28>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: <stable@vger.kernel.org> # v3.6..
Fixes: 7a623c039075 ("edac: rewrite the sysfs code to use struct device")
-rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index a75acea0f674..58aed67b7eba 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -880,21 +880,26 @@ static struct device_type mci_attr_type = { | |||
880 | int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, | 880 | int edac_create_sysfs_mci_device(struct mem_ctl_info *mci, |
881 | const struct attribute_group **groups) | 881 | const struct attribute_group **groups) |
882 | { | 882 | { |
883 | char *name; | ||
883 | int i, err; | 884 | int i, err; |
884 | 885 | ||
885 | /* | 886 | /* |
886 | * The memory controller needs its own bus, in order to avoid | 887 | * The memory controller needs its own bus, in order to avoid |
887 | * namespace conflicts at /sys/bus/edac. | 888 | * namespace conflicts at /sys/bus/edac. |
888 | */ | 889 | */ |
889 | mci->bus->name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx); | 890 | name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx); |
890 | if (!mci->bus->name) | 891 | if (!name) |
891 | return -ENOMEM; | 892 | return -ENOMEM; |
892 | 893 | ||
894 | mci->bus->name = name; | ||
895 | |||
893 | edac_dbg(0, "creating bus %s\n", mci->bus->name); | 896 | edac_dbg(0, "creating bus %s\n", mci->bus->name); |
894 | 897 | ||
895 | err = bus_register(mci->bus); | 898 | err = bus_register(mci->bus); |
896 | if (err < 0) | 899 | if (err < 0) { |
897 | goto fail_free_name; | 900 | kfree(name); |
901 | return err; | ||
902 | } | ||
898 | 903 | ||
899 | /* get the /sys/devices/system/edac subsys reference */ | 904 | /* get the /sys/devices/system/edac subsys reference */ |
900 | mci->dev.type = &mci_attr_type; | 905 | mci->dev.type = &mci_attr_type; |
@@ -961,8 +966,8 @@ fail_unregister_dimm: | |||
961 | device_unregister(&mci->dev); | 966 | device_unregister(&mci->dev); |
962 | fail_unregister_bus: | 967 | fail_unregister_bus: |
963 | bus_unregister(mci->bus); | 968 | bus_unregister(mci->bus); |
964 | fail_free_name: | 969 | kfree(name); |
965 | kfree(mci->bus->name); | 970 | |
966 | return err; | 971 | return err; |
967 | } | 972 | } |
968 | 973 | ||
@@ -993,10 +998,12 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) | |||
993 | 998 | ||
994 | void edac_unregister_sysfs(struct mem_ctl_info *mci) | 999 | void edac_unregister_sysfs(struct mem_ctl_info *mci) |
995 | { | 1000 | { |
1001 | const char *name = mci->bus->name; | ||
1002 | |||
996 | edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev)); | 1003 | edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev)); |
997 | device_unregister(&mci->dev); | 1004 | device_unregister(&mci->dev); |
998 | bus_unregister(mci->bus); | 1005 | bus_unregister(mci->bus); |
999 | kfree(mci->bus->name); | 1006 | kfree(name); |
1000 | } | 1007 | } |
1001 | 1008 | ||
1002 | static void mc_attr_release(struct device *dev) | 1009 | static void mc_attr_release(struct device *dev) |