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: <b18c2e4b-bf61-41ad-b5f9-8e52d7651cca@web.de>
Date: Fri, 19 Apr 2024 08:15:25 +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>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Matti Vaittinen <mazziesaccount@...il.com>,
 Maxime Ripard <mripard@...nel.org>, Rae Moar <rmoar@...gle.com>,
 Shuah Khan <skhan@...uxfoundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 2/2] kunit: avoid memory leak on device register error

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

Can a description variant (like the following) be more appropriate?

   Free the allocated memory (after a device registration failure)
   before returning.
   Thus add a jump target so that a bit of exception handling can be better
   reused at the end of this function implementation.


Would you like to replace the word “register” by “registration” also
in the summary phrase?


…
> +++ b/lib/kunit/device.c
…
> @@ -140,6 +138,9 @@ static struct kunit_device *kunit_device_register_internal(struct kunit *test,
>  	kunit_add_action(test, device_unregister_wrapper, &kunit_dev->dev);
>
>  	return kunit_dev;
> +error:
> +	kfree(kunit_dev);
> +	return ERR_PTR(err);
>  }
…

I find it nicer to use a label like free_device.

Regards,
Markus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ