Currently, unload work will be done successfully when specify "kexec -p -u". However, when exchange the sequence like "kexec -u -p" unload work can be done too, but with a usage printing. This is because in the former sequence, "-p" will do below assignments: do_load=0; do_unload=1; Then "-u" do below assignments. do_load=0; do_unload=1; Nothing wrong happened in this situation. Since the result woule be: "do_load==0" and do_unload==1. In the latter sequence, the final result will be "do_load==1" and "do_unload==1". Then after unload operation, it will go into loading code flow. Thsi cause the usage() calling and printing. So in this patch add a check when enter into the loading code flow. Signed-off-by: Baoquan He <bhe at redhat.com> --- kexec/kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec/kexec.c b/kexec/kexec.c index 7e7b604..87ec26a 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -1361,7 +1361,7 @@ int main(int argc, char *argv[]) else result = k_unload(kexec_flags); } - if (do_load && (result == 0)) { + if (do_load && !do_unload (result == 0)) { if (do_kexec_file_syscall) result = do_kexec_file_load(fileind, argc, argv, kexec_file_flags); -- 1.8.5.3