Re: [PATCH] regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



…
> - 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





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux