]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Fix file error handling regression
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 13 Nov 2024 22:32:55 +0000 (23:32 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 19 Nov 2024 06:24:58 +0000 (00:24 -0600)
The propagation of errors from loading function through errno must make
sure that errno is positive, otherwise errors are not correctly spotted.

Fixes: 81e5c797 ("libkmod: propagate {zstd,xz,zlib}_load errors")
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/242
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-file-zstd.c
libkmod/libkmod-file.c

index 098d107494a8b55e8076346197bc25b19357b996..9715000648567763e0e96490c3c1d94ad1d50e4e 100644 (file)
@@ -67,6 +67,7 @@ int kmod_file_load_zstd(struct kmod_file *file)
        ret = ZSTD_decompress(dst_buf, dst_size, src_buf, src_size);
        if (ZSTD_isError(ret)) {
                ERR(file->ctx, "zstd: %s\n", ZSTD_getErrorName(ret));
+               ret = -EINVAL;
                goto out;
        }
 
index 828522ec7f06a45a4b70fc35ac008b778c66fb8f..89f746419419246bdde3fe00298d594690d227f0 100644 (file)
@@ -67,7 +67,7 @@ struct kmod_elf *kmod_file_get_elf(struct kmod_file *file)
 
        err = kmod_file_load_contents(file);
        if (err) {
-               errno = err;
+               errno = -err;
                return NULL;
        }