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] [day] [month] [year] [list]
Message-ID: <Z1yVhPJjxKhsc7VE@google.com>
Date: Fri, 13 Dec 2024 12:13:56 -0800
From: Brian Norris <briannorris@...omium.org>
To: Maxime Ripard <mripard@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
	kunit-dev@...glegroups.com, David Gow <davidgow@...gle.com>,
	Rae Moar <rmoar@...gle.com>, linux-kselftest@...r.kernel.org,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Rob Herring <robh@...nel.org>
Subject: Re: [PATCH v2 3/3] drivers: base: test: Add ...find_device_by...(...
 NULL) tests

Hi Maxime,

On Fri, Dec 13, 2024 at 12:59:57PM +0100, Maxime Ripard wrote:
> On Wed, Dec 11, 2024 at 04:31:41PM -0800, Brian Norris wrote:
> > --- a/drivers/base/test/platform-device-test.c
> > +++ b/drivers/base/test/platform-device-test.c

> > @@ -217,7 +219,45 @@ 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 = platform_device_alloc(DEVICE_NAME, PLATFORM_DEVID_NONE);
> > +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
> > +
> > +	ret = platform_device_add(pdev);
> > +	KUNIT_ASSERT_EQ(test, ret, 0);
> 
> I *think* you have a bug there: if platform_device_add fails,
> KUNIT_ASSERT will stop the test execution and thus you will leak the
> platform_device you just allocated.
> 
> You need to call platform_device_put in such a case, but if
> platform_device_add succeeds then you need to call
> platform_device_unregister instead.

Hehe, well I'm imitating the existing leaks in the other tests in this
file, then ;) But admittedly, those are a little more complex, because
the unregistration is actually part of the test flow.

> It would be better to use kunit_platform_device_alloc and
> kunit_platform_device_add that already deal with this.

Cool, thanks, I'll use those in v3 for my new test.

> The rest looks good to me, once fixed:
> Reviewed-by: Maxime Ripard <mripard@...nel.org>

Thanks for the tips and review.

Brian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ