* [PATCH v2 0/2] kunit: fix minor error path mistakes
@ 2024-04-18 16:00 Wander Lairson Costa
2024-04-18 16:00 ` [PATCH v2 1/2] kunit: unregister the device on error Wander Lairson Costa
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wander Lairson Costa @ 2024-04-18 16:00 UTC (permalink / raw)
To: Brendan Higgins, David Gow, Rae Moar, Shuah Khan, Maxime Ripard,
Greg Kroah-Hartman, Matti Vaittinen,
open list:KERNEL UNIT TESTING FRAMEWORK (KUnit),
open list:KERNEL UNIT TESTING FRAMEWORK (KUnit), open list
Cc: Wander Lairson Costa
Hi,
These two patches fix some minor error path mistakes in the device
module.
Changes:
--------
v1->v2:
* Add fixes tag.
* Add an imperative statement in the first commit descripton.
Wander Lairson Costa (2):
kunit: unregister the device on error
kunit: avoid memory leak on device register error
lib/kunit/device.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--
2.44.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2 1/2] kunit: unregister the device on error
2024-04-18 16:00 [PATCH v2 0/2] kunit: fix minor error path mistakes Wander Lairson Costa
@ 2024-04-18 16:00 ` Wander Lairson Costa
2024-04-18 16:00 ` [PATCH v2 2/2] kunit: avoid memory leak on device register error Wander Lairson Costa
2024-04-18 16:18 ` [PATCH v2 0/2] kunit: fix minor error path mistakes Maxime Ripard
2 siblings, 0 replies; 4+ messages in thread
From: Wander Lairson Costa @ 2024-04-18 16:00 UTC (permalink / raw)
To: Brendan Higgins, David Gow, Rae Moar, Maxime Ripard, Shuah Khan,
Greg Kroah-Hartman, Matti Vaittinen,
open list:KERNEL UNIT TESTING FRAMEWORK (KUnit),
open list:KERNEL UNIT TESTING FRAMEWORK (KUnit), open list
Cc: Wander Lairson Costa
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")
---
lib/kunit/device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/kunit/device.c b/lib/kunit/device.c
index abc603730b8e..25c81ed465fb 100644
--- a/lib/kunit/device.c
+++ b/lib/kunit/device.c
@@ -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;
}
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] kunit: avoid memory leak on device register error
2024-04-18 16:00 [PATCH v2 0/2] kunit: fix minor error path mistakes Wander Lairson Costa
2024-04-18 16:00 ` [PATCH v2 1/2] kunit: unregister the device on error Wander Lairson Costa
@ 2024-04-18 16:00 ` Wander Lairson Costa
2024-04-18 16:18 ` [PATCH v2 0/2] kunit: fix minor error path mistakes Maxime Ripard
2 siblings, 0 replies; 4+ messages in thread
From: Wander Lairson Costa @ 2024-04-18 16:00 UTC (permalink / raw)
To: Brendan Higgins, David Gow, Rae Moar, Matti Vaittinen,
Greg Kroah-Hartman, Maxime Ripard, Shuah Khan,
open list:KERNEL UNIT TESTING FRAMEWORK (KUnit),
open list:KERNEL UNIT TESTING FRAMEWORK (KUnit), open list
Cc: Wander Lairson Costa
If the device register fails, free the allocated memory before
returning.
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Fixes: d03c720e03bd ("kunit: Add APIs for managing devices")
---
lib/kunit/device.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/kunit/device.c b/lib/kunit/device.c
index 25c81ed465fb..d8c09dcb3e79 100644
--- a/lib/kunit/device.c
+++ b/lib/kunit/device.c
@@ -131,6 +131,7 @@ static struct kunit_device *kunit_device_register_internal(struct kunit *test,
err = device_register(&kunit_dev->dev);
if (err) {
put_device(&kunit_dev->dev);
+ kfree(kunit_dev);
return ERR_PTR(err);
}
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 0/2] kunit: fix minor error path mistakes
2024-04-18 16:00 [PATCH v2 0/2] kunit: fix minor error path mistakes Wander Lairson Costa
2024-04-18 16:00 ` [PATCH v2 1/2] kunit: unregister the device on error Wander Lairson Costa
2024-04-18 16:00 ` [PATCH v2 2/2] kunit: avoid memory leak on device register error Wander Lairson Costa
@ 2024-04-18 16:18 ` Maxime Ripard
2 siblings, 0 replies; 4+ messages in thread
From: Maxime Ripard @ 2024-04-18 16:18 UTC (permalink / raw)
To: Wander Lairson Costa
Cc: Brendan Higgins, David Gow, Greg Kroah-Hartman, Matti Vaittinen,
Maxime Ripard, Rae Moar, Shuah Khan, open list,
"open list:KERNEL UNIT TESTING FRAMEWORK (KUnit)",
open list:KERNEL UNIT TESTING FRAMEWORK (KUnit)
On Thu, 18 Apr 2024 13:00:36 -0300, Wander Lairson Costa wrote:
> Hi,
>
> These two patches fix some minor error path mistakes in the device
> module.
>
>
> [ ... ]
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Thanks!
Maxime
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-18 16:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-18 16:00 [PATCH v2 0/2] kunit: fix minor error path mistakes Wander Lairson Costa
2024-04-18 16:00 ` [PATCH v2 1/2] kunit: unregister the device on error Wander Lairson Costa
2024-04-18 16:00 ` [PATCH v2 2/2] kunit: avoid memory leak on device register error Wander Lairson Costa
2024-04-18 16:18 ` [PATCH v2 0/2] kunit: fix minor error path mistakes Maxime Ripard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox