| 86a5f32e | 16-Dec-2024 |
Brian Norris <[email protected]> |
drivers: base: test: Add ...find_device_by...(... NULL) tests
We recently updated these device_match*() (and therefore, various *find_device_by*()) functions to return a consistent 'false' value whe
drivers: base: test: Add ...find_device_by...(... NULL) tests
We recently updated these device_match*() (and therefore, various *find_device_by*()) functions to return a consistent 'false' value when trying to match a NULL handle. Add tests for this.
This provides regression-testing coverage for the sorts of bugs that underly commit 5c8418cf4025 ("PCI/pwrctrl: Unregister platform device only if one actually exists").
Reviewed-by: Maxime Ripard <[email protected]> Signed-off-by: Brian Norris <[email protected]> Acked-by: Shuah Khan <[email protected]> Reviewed-by: David Gow <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| f7bb2426 | 16-Aug-2023 |
Maxime Ripard <[email protected]> |
drivers: base: test: Add missing MODULE_* macros to root device tests
Commit 06188bc80ccb ("drivers: base: Add basic devm tests for root devices") introduced a new set of tests for root devices that
drivers: base: test: Add missing MODULE_* macros to root device tests
Commit 06188bc80ccb ("drivers: base: Add basic devm tests for root devices") introduced a new set of tests for root devices that could be compiled as a module, but didn't have the usual module macros.
Make sure they're there.
Fixes: 06188bc80ccb ("drivers: base: Add basic devm tests for root devices") Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| f71b144e | 16-Aug-2023 |
Maxime Ripard <[email protected]> |
drivers: base: test: Add missing MODULE_* macros for platform devices tests
Commit b4cc44301b9d ("drivers: base: Add basic devm tests for platform devices") introduced a new set of tests for platfor
drivers: base: test: Add missing MODULE_* macros for platform devices tests
Commit b4cc44301b9d ("drivers: base: Add basic devm tests for platform devices") introduced a new set of tests for platform devices that could be compiled as a module, but didn't have the usual module macros.
Make sure they're there.
Fixes: b4cc44301b9d ("drivers: base: Add basic devm tests for platform devices") Reported-by: Stephen Rothwell <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| 699fb50d | 20-Jul-2023 |
David Gow <[email protected]> |
drivers: base: Free devm resources when unregistering a device
In the current code, devres_release_all() only gets called if the device has a bus and has been probed.
This leads to issues when usin
drivers: base: Free devm resources when unregistering a device
In the current code, devres_release_all() only gets called if the device has a bus and has been probed.
This leads to issues when using bus-less or driver-less devices where the device might never get freed if a managed resource holds a reference to the device. This is happening in the DRM framework for example.
We should thus call devres_release_all() in the device_del() function to make sure that the device-managed actions are properly executed when the device is unregistered, even if it has neither a bus nor a driver.
This is effectively the same change than commit 2f8d16a996da ("devres: release resources on device_del()") that got reverted by commit a525a3ddeaca ("driver core: free devres in device_release") over memory leaks concerns.
This patch effectively combines the two commits mentioned above to release the resources both on device_del() and device_release() and get the best of both worlds.
Fixes: a525a3ddeaca ("driver core: free devres in device_release") Signed-off-by: David Gow <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/20230720-kunit-devm-inconsistencies-test-v3-3-6aa7e074f373@kernel.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| b4cc4430 | 20-Jul-2023 |
Maxime Ripard <[email protected]> |
drivers: base: Add basic devm tests for platform devices
Platform devices show some inconsistencies with how devm resources are released when the device has been probed and when it hasn't.
In parti
drivers: base: Add basic devm tests for platform devices
Platform devices show some inconsistencies with how devm resources are released when the device has been probed and when it hasn't.
In particular, we can register device-managed actions no matter if the device has be bound to a driver or not, but devres_release_all() will only be called if it was bound to a driver or if there's no reference held to it anymore.
If it wasn't bound to a driver and we still have a reference, devres_release_all() will never get called. This is surprising considering that if the driver isn't bound but doesn't have any reference to it anymore, that function will get called, and if it was bound to a driver but still has references, that function will get called as well.
Even if that case is fairly unusual, it can easily lead to memory leaks.
The plan is, with the next patch, to make it consistent and enforce that devres_release_all() is called no matter what situation we're in. For now, it just tests for the current behaviour and skips over the inconsistencies.
Reviewed-by: David Gow <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/20230720-kunit-devm-inconsistencies-test-v3-2-6aa7e074f373@kernel.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
show more ...
|
| aa811e3c | 14-Jan-2020 |
Alan Maguire <[email protected]> |
software node: introduce CONFIG_KUNIT_DRIVER_PE_TEST
Currently the property entry kunit tests are built if CONFIG_KUNIT=y. This will cause warnings when merged with the kunit tree that now supports
software node: introduce CONFIG_KUNIT_DRIVER_PE_TEST
Currently the property entry kunit tests are built if CONFIG_KUNIT=y. This will cause warnings when merged with the kunit tree that now supports tristate CONFIG_KUNIT. While the tests appear to compile as a module, we get a warning about missing module license.
It's better to have a per-test suite CONFIG variable so that we can do selective building of kunit-based suites, and can also avoid merge issues like this.
Fixes: c032ace71c29 ("software node: add basic tests for property entries") Reported-by: Stephen Rothwell <[email protected]> Reported-by: Randy Dunlap <[email protected]> Signed-off-by: Alan Maguire <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
show more ...
|
| eabd5e7d | 06-Jan-2020 |
Qian Cai <[email protected]> |
drivers/base/test: fix global-out-of-bounds error
Commit c032ace71c29 ("software node: add basic tests for property entries") introduced a global-out-of-bounds error because it forgot to add a termi
drivers/base/test: fix global-out-of-bounds error
Commit c032ace71c29 ("software node: add basic tests for property entries") introduced a global-out-of-bounds error because it forgot to add a terminator of "nodes "for software_node_register_nodes() to process.
# Subtest: property-entry 1..7 ok 1 - pe_test_uints ok 2 - pe_test_uint_arrays ok 3 - pe_test_strings ok 4 - pe_test_bool ok 5 - pe_test_move_inline_u8 ok 6 - pe_test_move_inline_str ================================================================== BUG: KASAN: global-out-of-bounds in software_node_register_nodes+0x41/0x80 Read of size 8 at addr ffffffff989ef250 by task kunit_try_catch/316
CPU: 17 PID: 316 Comm: kunit_try_catch Not tainted 5.5.0-rc4-next-20200106+ #1 Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 03/09/2018 Call Trace: dump_stack+0xa0/0xea print_address_description.constprop.5.cold.7+0x64/0x384 __kasan_report.cold.8+0x7a/0xc0 kasan_report+0x12/0x20 __asan_load8+0x71/0xa0 software_node_register_nodes+0x41/0x80 pe_test_reference+0x1eb/0x1200 kunit_try_run_case+0x6b/0xd1 kunit_generic_run_threadfn_adapter+0x29/0x50 kthread+0x1e6/0x210 ret_from_fork+0x27/0x50
The buggy address belongs to the variable: nodes.21544+0x30/0x920
Memory state around the buggy address: ffffffff989ef100: fa fa fa fa 00 04 fa fa fa fa fa fa 00 00 00 00 ffffffff989ef180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffffffff989ef200: fa fa fa fa 00 00 00 00 00 00 fa fa fa fa fa fa ^ ffffffff989ef280: 00 06 fa fa fa fa fa fa 00 00 04 fa fa fa fa fa ffffffff989ef300: 00 00 fa fa fa fa fa fa 00 05 fa fa fa fa fa fa ================================================================== Disabling lock debugging due to kernel taint ok 7 - pe_test_reference ok 8 - property-entry
Fixes: c032ace71c29 ("software node: add basic tests for property entries") Signed-off-by: Qian Cai <[email protected]> Reviewed-by: Dmitry Torokhov <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
show more ...
|