[PATCH v2] KEYS: fix memory leaks when reading certificate

David Howells dhowells at redhat.com
Wed Mar 30 15:37:14 UTC 2022


Denis Glazkov <d.glazkov at omp.ru> 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



More information about the Linux-security-module-archive mailing list