@@ -977,21 +977,26 @@ static int edac_create_debug_nodes(struct mem_ctl_info *mci)
977
977
int edac_create_sysfs_mci_device (struct mem_ctl_info * mci ,
978
978
const struct attribute_group * * groups )
979
979
{
980
+ char * name ;
980
981
int i , err ;
981
982
982
983
/*
983
984
* The memory controller needs its own bus, in order to avoid
984
985
* namespace conflicts at /sys/bus/edac.
985
986
*/
986
- mci -> bus -> name = kasprintf (GFP_KERNEL , "mc%d" , mci -> mc_idx );
987
- if (!mci -> bus -> name )
987
+ name = kasprintf (GFP_KERNEL , "mc%d" , mci -> mc_idx );
988
+ if (!name )
988
989
return - ENOMEM ;
989
990
991
+ mci -> bus -> name = name ;
992
+
990
993
edac_dbg (0 , "creating bus %s\n" , mci -> bus -> name );
991
994
992
995
err = bus_register (mci -> bus );
993
- if (err < 0 )
994
- goto fail_free_name ;
996
+ if (err < 0 ) {
997
+ kfree (name );
998
+ return err ;
999
+ }
995
1000
996
1001
/* get the /sys/devices/system/edac subsys reference */
997
1002
mci -> dev .type = & mci_attr_type ;
@@ -1060,8 +1065,8 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci,
1060
1065
device_unregister (& mci -> dev );
1061
1066
fail_unregister_bus :
1062
1067
bus_unregister (mci -> bus );
1063
- fail_free_name :
1064
- kfree ( mci -> bus -> name );
1068
+ kfree ( name );
1069
+
1065
1070
return err ;
1066
1071
}
1067
1072
@@ -1092,10 +1097,12 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
1092
1097
1093
1098
void edac_unregister_sysfs (struct mem_ctl_info * mci )
1094
1099
{
1100
+ const char * name = mci -> bus -> name ;
1101
+
1095
1102
edac_dbg (1 , "Unregistering device %s\n" , dev_name (& mci -> dev ));
1096
1103
device_unregister (& mci -> dev );
1097
1104
bus_unregister (mci -> bus );
1098
- kfree (mci -> bus -> name );
1105
+ kfree (name );
1099
1106
}
1100
1107
1101
1108
static void mc_attr_release (struct device * dev )
0 commit comments