]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kunit: unregister the device on error
authorWander Lairson Costa <wander@redhat.com>
Fri, 19 Apr 2024 13:25:01 +0000 (10:25 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 May 2024 07:49:21 +0000 (09:49 +0200)
[ Upstream commit fabd480b721eb30aa4e2c89507b53933069f9f6e ]

kunit_init_device() should unregister the device on bus register error,
but mistakenly it tries to unregister the bus.

Unregister the device instead of the bus.

Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Fixes: d03c720e03bd ("kunit: Add APIs for managing devices")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/kunit/device.c

index 9ea399049749e512ec83db99a0823c867a6c8f88..3a31fe9ed6fc5bbcfd492051e63ed11a21d18b79 100644 (file)
@@ -51,7 +51,7 @@ int kunit_bus_init(void)
 
        error = bus_register(&kunit_bus_type);
        if (error)
-               bus_unregister(&kunit_bus_type);
+               root_device_unregister(kunit_bus_device);
        return error;
 }