aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2020-12-18 08:02:07 -0800
committerLucas De Marchi <lucas.demarchi@intel.com>2020-12-27 16:40:08 -0800
commit220b4c55ec219d6a9e10fc343df4691fbe5339b1 (patch)
treea300c40b6ae0aa64697372f758fbccd813393542
parent4bd8586c208dd2a84049c7b8b7d20f79d932b999 (diff)
downloadkmod-220b4c55ec219d6a9e10fc343df4691fbe5339b1.tar.gz
depmod: unconditionally write builtin.alias.bin
The file is always created and unless we return an error, the temporary file is renamed to its final destination. All other places write the index without checking if the index is empty, so just do the same. Reported-by: Joe Buehler <aspam@cox.net>
-rw-r--r--tools/depmod.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index 2c03dfe..3f31cdf 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2419,7 +2419,7 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
if (ret < 0) {
if (ret == -ENOENT)
ret = 0;
- goto fail;
+ goto out;
}
kmod_list_foreach(l, builtin) {
@@ -2429,7 +2429,7 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
ret = kmod_module_get_info(mod, &info_list);
if (ret < 0)
- goto fail;
+ goto out;
kmod_list_foreach(ll, info_list) {
char alias[PATH_MAX];
@@ -2454,9 +2454,11 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
count++;
}
- if (count)
+out:
+ /* do not bother writing the index if we are going to discard it */
+ if (!ret)
index_write(idx, out);
-fail:
+
if (builtin)
kmod_module_unref_list(builtin);