diff options
author | Yauheni Kaliuta <yauheni.kaliuta@redhat.com> | 2020-11-29 18:47:35 +0200 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2020-12-01 00:44:17 -0800 |
commit | 47807c4cfa5ffe1e5da27e3d3056d9b47ba998c5 (patch) | |
tree | 109a5b8f307acf8bb105cd2e7e66ef2ea9603e33 | |
parent | 2f38000256d63f77a36cc49040436ba8647d09af (diff) | |
download | kmod-47807c4cfa5ffe1e5da27e3d3056d9b47ba998c5.tar.gz kmod-47807c4cfa5ffe1e5da27e3d3056d9b47ba998c5.tar.bz2 kmod-47807c4cfa5ffe1e5da27e3d3056d9b47ba998c5.zip |
libkmod: kmod_builtin_get_modinfo: free modinfo on error
The function allocates array but on building it if get_string()
fails it returns the error leaving the array allocated. The caller
does not care about it in error case either.
Free it to fix memory leak.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
-rw-r--r-- | libkmod/libkmod-builtin.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c index aaec5dd..fc9a376 100644 --- a/libkmod/libkmod-builtin.c +++ b/libkmod/libkmod-builtin.c @@ -314,6 +314,7 @@ ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname, offset = get_string(iter, pos, &line, &linesz); if (offset <= 0) { count = (offset) ? -errno : -EOF; + free(*modinfo); goto fail; } |