diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 12eec3f633b13f0b6e6544a6ce895ff298d4cd84..eb1b7fa20dce5af66c6711d05e97642ce4c568a1 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -945,8 +945,8 @@ bus_devices_fail:
 	bus_remove_file(bus, &bus_attr_uevent);
 bus_uevent_fail:
 	kset_unregister(&bus->p->subsys);
-	kfree(bus->p);
 out:
+	kfree(bus->p);
 	bus->p = NULL;
 	return retval;
 }