Messages in this thread Patch in this message | | | Date | Thu, 11 Apr 2024 13:30:30 +0200 | Subject | Re: [PATCH] regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap() | From | Markus Elfring <> |
| |
… > - 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
| |