lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABVgOSkL3iCA9j553GM8pX_SZ80Xx+BWGZ_qaL0jHAY69-WMmg@mail.gmail.com>
Date: Thu, 19 Dec 2024 13:45:13 +0800
From: David Gow <davidgow@...gle.com>
To: Brian Norris <briannorris@...omium.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Maxime Ripard <mripard@...nel.org>, 
	linux-acpi@...r.kernel.org, Rae Moar <rmoar@...gle.com>, 
	Rob Herring <robh@...nel.org>, linux-kselftest@...r.kernel.org, 
	"Rafael J. Wysocki" <rafael@...nel.org>, kunit-dev@...glegroups.com, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 3/3] drivers: base: test: Add ...find_device_by...(...
 NULL) tests

On Tue, 17 Dec 2024 at 04:12, Brian Norris <briannorris@...omium.org> wrote:
>
> 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 <mripard@...nel.org>
> Signed-off-by: Brian Norris <briannorris@...omium.org>
> ---
>

Thanks. This looks good to me.

Reviewed-by: David Gow <davidgow@...gle.com>


-- David

> Changes in v3:
>  * Fix potential leak in test error case
>  * Add Maxime's Reviewed-by
>
> Changes in v2:
>  * Keep "devm" and "match" tests in separate suites
>
>  drivers/base/test/platform-device-test.c | 41 +++++++++++++++++++++++-
>  1 file changed, 40 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/test/platform-device-test.c b/drivers/base/test/platform-device-test.c
> index ea05b8785743..6355a2231b74 100644
> --- a/drivers/base/test/platform-device-test.c
> +++ b/drivers/base/test/platform-device-test.c
> @@ -1,8 +1,11 @@
>  // SPDX-License-Identifier: GPL-2.0
>
> +#include <kunit/platform_device.h>
>  #include <kunit/resource.h>
>
>  #include <linux/device.h>
> +#include <linux/device/bus.h>
> +#include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>
>  #define DEVICE_NAME "test"
> @@ -217,7 +220,43 @@ static struct kunit_suite platform_device_devm_test_suite = {
>         .test_cases = platform_device_devm_tests,
>  };
>
> -kunit_test_suite(platform_device_devm_test_suite);
> +static void platform_device_find_by_null_test(struct kunit *test)
> +{
> +       struct platform_device *pdev;
> +       int ret;
> +
> +       pdev = kunit_platform_device_alloc(test, DEVICE_NAME, PLATFORM_DEVID_NONE);
> +       KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
> +
> +       ret = kunit_platform_device_add(test, pdev);
> +       KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +       KUNIT_EXPECT_PTR_EQ(test, of_find_device_by_node(NULL), NULL);
> +
> +       KUNIT_EXPECT_PTR_EQ(test, bus_find_device_by_of_node(&platform_bus_type, NULL), NULL);
> +       KUNIT_EXPECT_PTR_EQ(test, bus_find_device_by_fwnode(&platform_bus_type, NULL), NULL);
> +       KUNIT_EXPECT_PTR_EQ(test, bus_find_device_by_acpi_dev(&platform_bus_type, NULL), NULL);
> +
> +       KUNIT_EXPECT_FALSE(test, device_match_of_node(&pdev->dev, NULL));
> +       KUNIT_EXPECT_FALSE(test, device_match_fwnode(&pdev->dev, NULL));
> +       KUNIT_EXPECT_FALSE(test, device_match_acpi_dev(&pdev->dev, NULL));
> +       KUNIT_EXPECT_FALSE(test, device_match_acpi_handle(&pdev->dev, NULL));
> +}
> +
> +static struct kunit_case platform_device_match_tests[] = {
> +       KUNIT_CASE(platform_device_find_by_null_test),
> +       {}
> +};
> +
> +static struct kunit_suite platform_device_match_test_suite = {
> +       .name = "platform-device-match",
> +       .test_cases = platform_device_match_tests,
> +};
> +
> +kunit_test_suites(
> +       &platform_device_devm_test_suite,
> +       &platform_device_match_test_suite,
> +);
>
>  MODULE_DESCRIPTION("Test module for platform devices");
>  MODULE_AUTHOR("Maxime Ripard <mripard@...nel.org>");
> --
> 2.47.1.613.gc27f4b7a9f-goog
>

Download attachment "smime.p7s" of type "application/pkcs7-signature" (5294 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ