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: <9ff84256-c7d2-48e5-b06b-09a993db2c39@web.de>
Date: Thu, 18 Apr 2024 17:24:47 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: Wander Lairson Costa <wander@...hat.com>, kunit-dev@...glegroups.com,
 linux-kselftest@...r.kernel.org, kernel-janitors@...r.kernel.org,
 Brendan Higgins <brendan.higgins@...ux.dev>, David Gow
 <davidgow@...gle.com>, Rae Moar <rmoar@...gle.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] kunit: avoid memory leak on device register error

> If the device register fails, free the allocated memory before
> returning.

* I suggest to use the word “registration” (instead of “register”)
  in the commit message.

* Would you like to add the tag “Fixes” accordingly?


> +++ 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);
>  	}

Common error handling code can be used instead
if an additional label would be applied for a corresponding jump target.

How do you think about to increase the application of scope-based resource management here?

Regards,
Markus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ