From e90f0704ea81c4e90663c4e8ea91e475f0b6aa36 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 24 Feb 2015 23:58:39 -0300 Subject: [PATCH] depmod: fix leaking root on exit --- tools/depmod.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/depmod.c b/tools/depmod.c index d25f76b..a4a7479 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -2404,7 +2404,7 @@ static int do_depmod(int argc, char *argv[]) maybe_all = 1; break; case 'b': - root = path_make_absolute_cwd(optarg); + root = optarg; break; case 'C': { size_t bytes = sizeof(char *) * (n_config_paths + 2); @@ -2483,6 +2483,9 @@ static int do_depmod(int argc, char *argv[]) cfg.kversion = un.release; } + if (root) + root = path_make_absolute_cwd(optarg); + cfg.dirnamelen = snprintf(cfg.dirname, PATH_MAX, "%s/lib/modules/%s", root == NULL ? "" : root, cfg.kversion); @@ -2594,6 +2597,7 @@ done: depmod_shutdown(&depmod); cfg_free(&cfg); free(config_paths); + free(root); return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE; cmdline_modules_failed: -- 2.7.4