Commit 4f77da63 authored by Petr Tesarik's avatar Petr Tesarik Committed by Simon Horman
Browse files

kexec-tools: Fix kexec_file_load(2) error handling



The handling of kexec_file_load() error conditions needs some
improvement.

First, on failure, the system call itself returns -1 and sets
errno. It is wrong to check the return value itself.

Second, do_kexec_file_load() mixes different types of error
codes (-1, return value of a load method, negative kernel error
number). Let it always return one of the reason codes defined in
kexec/kexec.h.

Third, the caller of do_kexec_file_load() cannot know what exactly
failed inside that function, so it should not check errno directly.
All it needs to know is whether it makes sense to fall back to the
other syscall. Add an error code for that purpose (EFALLBACK), and
let do_kexec_file_load() decide.

Fourth, do_kexec_file_load() should not print any error message if
it returns EFALLBACK, because the fallback syscall may succeed
later, and the user is confused whether the command failed, or not.
Move the error message towards the end of main().

Signed-off-by: default avatarPetr Tesarik <ptesarik@suse.com>
Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
parent a4afe68d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment