driver core: bus: Fix double free in driver API bus_register()
commit bfa54a793b upstream.
For bus_register(), any error which happens after kset_register() will
cause that @priv are freed twice, fixed by setting @priv with NULL after
the first free.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20240727-bus_register_fix-v1-1-fed8dd0dba7a@quicinc.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Brennan : Backport requires bus->p = NULL instead of priv = NULL ]
Signed-off-by: Brennan Lamoreaux <brennan.lamoreaux@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d5a63a0bc8
commit
fc1f391a71
@@ -853,6 +853,8 @@ bus_devices_fail:
|
||||
bus_remove_file(bus, &bus_attr_uevent);
|
||||
bus_uevent_fail:
|
||||
kset_unregister(&bus->p->subsys);
|
||||
/* Above kset_unregister() will kfree @bus->p */
|
||||
bus->p = NULL;
|
||||
out:
|
||||
kfree(bus->p);
|
||||
bus->p = NULL;
|
||||
|
||||
Reference in New Issue
Block a user