From: Karel Zak Date: Wed, 12 Mar 2025 13:11:49 +0000 (+0100) Subject: libmount: remove possible leak in mnt_context_guess_srcpath_fstype() [coverity scan] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e2127384ba267119311437b233e413e16ef8721;p=thirdparty%2Futil-linux.git libmount: remove possible leak in mnt_context_guess_srcpath_fstype() [coverity scan] Signed-off-by: Karel Zak --- diff --git a/libmount/src/context.c b/libmount/src/context.c index 3c1258882..0323cb23d 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -2023,8 +2023,11 @@ int mnt_context_guess_srcpath_fstype(struct libmnt_context *cxt, char **type) struct libmnt_opt *opt; const char *allowed; - if (!ol) + if (!ol) { + free(*type); + *type = NULL; return -ENOMEM; + } opt = mnt_optlist_get_named(ol, "X-mount.auto-fstypes", cxt->map_userspace); diff --git a/libmount/src/hook_loopdev.c b/libmount/src/hook_loopdev.c index 4f831e0d8..444d69d6f 100644 --- a/libmount/src/hook_loopdev.c +++ b/libmount/src/hook_loopdev.c @@ -458,6 +458,7 @@ static int is_loopdev_required(struct libmnt_context *cxt, struct libmnt_optlist rc = mnt_context_guess_srcpath_fstype(cxt, &autotype); if (rc) { + free(autotype);; DBG(CXT, ul_debugobj(cxt, "failed to guess regfile FS type [rc=%d]", rc)); return 0; }