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: <505b6da5-93ca-481d-ab57-c246ad9a4eaf@web.de>
Date: Thu, 11 Apr 2024 13:30:30 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: Richard Fitzgerald <rf@...nsource.cirrus.com>,
 patches@...nsource.cirrus.com, kernel-janitors@...r.kernel.org,
 Mark Brown <broonie@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] regmap: kunit: Fix memory leaks in gen_regmap() and
 gen_raw_regmap()

…
> - kfree() the buf and *data buffers on the error paths.
…

Will development interests grow for scope-based resource management?


…
+++ b/drivers/base/regmap/regmap-kunit.c
@@ -145,9 +145,9 @@ static struct regmap *gen_regmap(struct kunit *test,
…
-	struct regmap *ret;
+	struct regmap *ret = ERR_PTR(-ENOMEM);
…

How do you think about to use the statement “return ERR_PTR(-ENOMEM);” at the end
instead of the extra variable initialisation?


…
@@ -172,15 +172,17 @@ static struct regmap *gen_regmap(struct kunit *test,

 	*data = kzalloc(sizeof(**data), GFP_KERNEL);
 	if (!(*data))
-		return ERR_PTR(-ENOMEM);
+		goto out_free;
…

I suggest to reconsider the label selection.

Regards,
Markus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ