@@ -973,21 +973,26 @@ int edac_create_debug_nodes(struct mem_ctl_info *mci)
973
973
*/
974
974
int edac_create_sysfs_mci_device (struct mem_ctl_info * mci )
975
975
{
976
+ char * name ;
976
977
int i , err ;
977
978
978
979
/*
979
980
* The memory controller needs its own bus, in order to avoid
980
981
* namespace conflicts at /sys/bus/edac.
981
982
*/
982
- mci -> bus -> name = kasprintf (GFP_KERNEL , "mc%d" , mci -> mc_idx );
983
- if (!mci -> bus -> name )
983
+ name = kasprintf (GFP_KERNEL , "mc%d" , mci -> mc_idx );
984
+ if (!name )
984
985
return - ENOMEM ;
985
986
987
+ mci -> bus -> name = name ;
988
+
986
989
edac_dbg (0 , "creating bus %s\n" , mci -> bus -> name );
987
990
988
991
err = bus_register (mci -> bus );
989
- if (err < 0 )
992
+ if (err < 0 ) {
993
+ kfree (name );
990
994
return err ;
995
+ }
991
996
992
997
/* get the /sys/devices/system/edac subsys reference */
993
998
mci -> dev .type = & mci_attr_type ;
@@ -1071,7 +1076,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1071
1076
fail2 :
1072
1077
device_unregister (& mci -> dev );
1073
1078
bus_unregister (mci -> bus );
1074
- kfree (mci -> bus -> name );
1079
+ kfree (name );
1080
+
1075
1081
return err ;
1076
1082
}
1077
1083
@@ -1102,10 +1108,12 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
1102
1108
1103
1109
void edac_unregister_sysfs (struct mem_ctl_info * mci )
1104
1110
{
1111
+ const char * name = mci -> bus -> name ;
1112
+
1105
1113
edac_dbg (1 , "Unregistering device %s\n" , dev_name (& mci -> dev ));
1106
1114
device_unregister (& mci -> dev );
1107
1115
bus_unregister (mci -> bus );
1108
- kfree (mci -> bus -> name );
1116
+ kfree (name );
1109
1117
}
1110
1118
1111
1119
static void mc_attr_release (struct device * dev )
0 commit comments