From: Tobias Stoeckmann Date: Tue, 10 Sep 2024 18:06:11 +0000 (+0200) Subject: depmod: Check strdup return value X-Git-Tag: v34~326 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec0c0f8520c2edcba63e0443946505985bbf9541;p=thirdparty%2Fkmod.git depmod: Check strdup return value If strdup fails, return error. Signed-off-by: Tobias Stoeckmann Link: https://github.com/kmod-project/kmod/pull/130 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index 90509d32..0326a5f0 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -1034,6 +1034,10 @@ static int depmod_module_add(struct depmod *depmod, struct kmod_module *kmod) array_init(&mod->deps, 4); mod->path = strdup(kmod_module_get_path(kmod)); + if (mod->path == NULL) { + free(mod); + return -ENOMEM; + } lastslash = strrchr(mod->path, '/'); mod->baselen = lastslash - mod->path; if (strncmp(mod->path, cfg->dirname, cfg->dirnamelen) == 0 &&