From: Markus Elfring <Markus.Elfring@web.de>
To: Richard Fitzgerald <rf@opensource.cirrus.com>,
patches@opensource.cirrus.com, kernel-janitors@vger.kernel.org,
Mark Brown <broonie@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap()
Date: Thu, 11 Apr 2024 13:30:30 +0200 [thread overview]
Message-ID: <505b6da5-93ca-481d-ab57-c246ad9a4eaf@web.de> (raw)
In-Reply-To: <20240411103724.54063-1-rf@opensource.cirrus.com>
…
> - 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
prev parent reply other threads:[~2024-04-11 11:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 10:37 Richard Fitzgerald
2024-04-11 11:30 ` Markus Elfring [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=505b6da5-93ca-481d-ab57-c246ad9a4eaf@web.de \
--to=markus.elfring@web.de \
--cc=broonie@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®