Skip to content

Commit

Permalink
libkmod: Fix file error handling regression
Browse files Browse the repository at this point in the history
The propagation of errors from loading function through errno must make
sure that errno is positive, otherwise errors are not correctly spotted.

Signed-off-by: Tobias Stoeckmann <[email protected]>
  • Loading branch information
stoeckmann committed Nov 13, 2024
1 parent 5c24480 commit 31067d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions libkmod/libkmod-file-zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion libkmod/libkmod-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 31067d7

Please sign in to comment.