]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: check for NULL in kmod_get_dirname
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 4 Sep 2024 16:21:17 +0000 (18:21 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 6 Sep 2024 15:54:57 +0000 (10:54 -0500)
The other KMOD_EXPORT'ed functions protect against ctx being NULL.
Add this to kmod_get_dirname purely for consistency reasons.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/102
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod.c

index 61efe2d646e8ba9f33e48efc2e7e07c91c2bc7fa..86025514bed111e95859c97857a863955b33ced6 100644 (file)
@@ -146,6 +146,9 @@ static void log_filep(void *data,
  */
 KMOD_EXPORT const char *kmod_get_dirname(const struct kmod_ctx *ctx)
 {
+       if (ctx == NULL)
+               return NULL;
+
        return ctx->dirname;
 }