Skip to content

Commit f46ef77

Browse files
suryasaimadhugregkh
authored andcommitted
EDAC: Fix lockdep splat
commit 88d84ac upstream. Fix the following: BUG: key ffff88043bdd0330 not in .data! ------------[ cut here ]------------ WARNING: at kernel/lockdep.c:2987 lockdep_init_map+0x565/0x5a0() DEBUG_LOCKS_WARN_ON(1) Modules linked in: glue_helper sb_edac(+) edac_core snd acpi_cpufreq lrw gf128mul ablk_helper iTCO_wdt evdev i2c_i801 dcdbas button cryptd pcspkr iTCO_vendor_support usb_common lpc_ich mfd_core soundcore mperf processor microcode CPU: 2 PID: 599 Comm: modprobe Not tainted 3.10.0 #1 Hardware name: Dell Inc. Precision T3600/0PTTT9, BIOS A08 01/24/2013 0000000000000009 ffff880439a1d920 ffffffff8160a9a9 ffff880439a1d958 ffffffff8103d9e0 ffff88043af4a510 ffffffff81a16e11 0000000000000000 ffff88043bdd0330 0000000000000000 ffff880439a1d9b8 ffffffff8103dacc Call Trace: dump_stack warn_slowpath_common warn_slowpath_fmt lockdep_init_map ? trace_hardirqs_on_caller ? trace_hardirqs_on debug_mutex_init __mutex_init bus_register edac_create_sysfs_mci_device edac_mc_add_mc sbridge_probe pci_device_probe driver_probe_device __driver_attach ? driver_probe_device bus_for_each_dev driver_attach bus_add_driver driver_register __pci_register_driver ? 0xffffffffa0010fff sbridge_init ? 0xffffffffa0010fff do_one_initcall load_module ? unset_module_init_ro_nx SyS_init_module tracesys ---[ end trace d24a70b0d3ddf733 ]--- EDAC MC0: Giving out device to 'sbridge_edac.c' 'Sandy Bridge Socket#0': DEV 0000:3f:0e.0 EDAC sbridge: Driver loaded. What happens is that bus_register needs a statically allocated lock_key because the last is handed in to lockdep. However, struct mem_ctl_info embeds struct bus_type (the whole struct, not a pointer to it) and the whole thing gets dynamically allocated. Fix this by using a statically allocated struct bus_type for the MC bus. Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Mauro Carvalho Chehab <[email protected]> Cc: Markus Trippelsdorf <[email protected]> Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5e20e8b commit f46ef77

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

drivers/edac/edac_mc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ static LIST_HEAD(mc_devices);
4848
*/
4949
static void const *edac_mc_owner;
5050

51+
static struct bus_type mc_bus[EDAC_MAX_MCS];
52+
5153
unsigned edac_dimm_info_location(struct dimm_info *dimm, char *buf,
5254
unsigned len)
5355
{
@@ -723,6 +725,11 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
723725
int ret = -EINVAL;
724726
edac_dbg(0, "\n");
725727

728+
if (mci->mc_idx >= EDAC_MAX_MCS) {
729+
pr_warn_once("Too many memory controllers: %d\n", mci->mc_idx);
730+
return -ENODEV;
731+
}
732+
726733
#ifdef CONFIG_EDAC_DEBUG
727734
if (edac_debug_level >= 3)
728735
edac_mc_dump_mci(mci);
@@ -762,6 +769,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
762769
/* set load time so that error rate can be tracked */
763770
mci->start_time = jiffies;
764771

772+
mci->bus = &mc_bus[mci->mc_idx];
773+
765774
if (edac_create_sysfs_mci_device(mci)) {
766775
edac_mc_printk(mci, KERN_WARNING,
767776
"failed to create sysfs device\n");

drivers/edac/edac_mc_sysfs.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
370370
return -ENODEV;
371371

372372
csrow->dev.type = &csrow_attr_type;
373-
csrow->dev.bus = &mci->bus;
373+
csrow->dev.bus = mci->bus;
374374
device_initialize(&csrow->dev);
375375
csrow->dev.parent = &mci->dev;
376376
csrow->mci = mci;
@@ -605,7 +605,7 @@ static int edac_create_dimm_object(struct mem_ctl_info *mci,
605605
dimm->mci = mci;
606606

607607
dimm->dev.type = &dimm_attr_type;
608-
dimm->dev.bus = &mci->bus;
608+
dimm->dev.bus = mci->bus;
609609
device_initialize(&dimm->dev);
610610

611611
dimm->dev.parent = &mci->dev;
@@ -975,11 +975,13 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
975975
* The memory controller needs its own bus, in order to avoid
976976
* namespace conflicts at /sys/bus/edac.
977977
*/
978-
mci->bus.name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx);
979-
if (!mci->bus.name)
978+
mci->bus->name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx);
979+
if (!mci->bus->name)
980980
return -ENOMEM;
981-
edac_dbg(0, "creating bus %s\n", mci->bus.name);
982-
err = bus_register(&mci->bus);
981+
982+
edac_dbg(0, "creating bus %s\n", mci->bus->name);
983+
984+
err = bus_register(mci->bus);
983985
if (err < 0)
984986
return err;
985987

@@ -988,7 +990,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
988990
device_initialize(&mci->dev);
989991

990992
mci->dev.parent = mci_pdev;
991-
mci->dev.bus = &mci->bus;
993+
mci->dev.bus = mci->bus;
992994
dev_set_name(&mci->dev, "mc%d", mci->mc_idx);
993995
dev_set_drvdata(&mci->dev, mci);
994996
pm_runtime_forbid(&mci->dev);
@@ -997,8 +999,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
997999
err = device_add(&mci->dev);
9981000
if (err < 0) {
9991001
edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));
1000-
bus_unregister(&mci->bus);
1001-
kfree(mci->bus.name);
1002+
bus_unregister(mci->bus);
1003+
kfree(mci->bus->name);
10021004
return err;
10031005
}
10041006

@@ -1064,8 +1066,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
10641066
}
10651067
fail2:
10661068
device_unregister(&mci->dev);
1067-
bus_unregister(&mci->bus);
1068-
kfree(mci->bus.name);
1069+
bus_unregister(mci->bus);
1070+
kfree(mci->bus->name);
10691071
return err;
10701072
}
10711073

@@ -1098,8 +1100,8 @@ void edac_unregister_sysfs(struct mem_ctl_info *mci)
10981100
{
10991101
edac_dbg(1, "Unregistering device %s\n", dev_name(&mci->dev));
11001102
device_unregister(&mci->dev);
1101-
bus_unregister(&mci->bus);
1102-
kfree(mci->bus.name);
1103+
bus_unregister(mci->bus);
1104+
kfree(mci->bus->name);
11031105
}
11041106

11051107
static void mc_attr_release(struct device *dev)

drivers/edac/i5100_edac.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ static int i5100_setup_debugfs(struct mem_ctl_info *mci)
974974
if (!i5100_debugfs)
975975
return -ENODEV;
976976

977-
priv->debugfs = debugfs_create_dir(mci->bus.name, i5100_debugfs);
977+
priv->debugfs = debugfs_create_dir(mci->bus->name, i5100_debugfs);
978978

979979
if (!priv->debugfs)
980980
return -ENOMEM;

include/linux/edac.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ struct edac_raw_error_desc {
622622
*/
623623
struct mem_ctl_info {
624624
struct device dev;
625-
struct bus_type bus;
625+
struct bus_type *bus;
626626

627627
struct list_head link; /* for global list of mem_ctl_info structs */
628628

@@ -742,4 +742,9 @@ struct mem_ctl_info {
742742
#endif
743743
};
744744

745+
/*
746+
* Maximum number of memory controllers in the coherent fabric.
747+
*/
748+
#define EDAC_MAX_MCS 16
749+
745750
#endif

0 commit comments

Comments
 (0)