Re: [PATCH v2] KEYS: fix memory leaks when reading certificate
From: David Howells
Date: Wed Mar 30 2022 - 11:37:28 EST
Denis Glazkov <d.glazkov@xxxxxx> wrote:
> The `exit()` function usage produce possible memory leaks. This
> patch removes the use of the `exit()` function and adds memory
> free in case of a negative scenarios.
?
Barring a kernel bug, there should be no memory leaks from exit(). _exit() is
the ultimate process cleanup tool. Calling free() won't necessarily return
the memory allocated by malloc() to the kernel.
Unless you have a good reason to actually tear down everything, just print a
message and call exit on error in little helpers like this.
David