Commit 3d26dcf7679c5cc6c9f3b95ffdb2152fba2b7fae
Committed by
Linus Torvalds
1 parent
4cafbd0b94
Exists in
master
and in
4 other branches
kernel/sys.c: clean up sys_shutdown exit path
Impact: cleanup, fix Clean up sys_shutdown() exit path. Factor out common code. Return correct error code instead of always 0 on failure. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 9 additions and 15 deletions Side-by-side Diff
kernel/sys.c
... | ... | @@ -360,6 +360,7 @@ |
360 | 360 | void __user *, arg) |
361 | 361 | { |
362 | 362 | char buffer[256]; |
363 | + int ret = 0; | |
363 | 364 | |
364 | 365 | /* We only trust the superuser with rebooting the system. */ |
365 | 366 | if (!capable(CAP_SYS_BOOT)) |
... | ... | @@ -397,7 +398,7 @@ |
397 | 398 | kernel_halt(); |
398 | 399 | unlock_kernel(); |
399 | 400 | do_exit(0); |
400 | - break; | |
401 | + panic("cannot halt"); | |
401 | 402 | |
402 | 403 | case LINUX_REBOOT_CMD_POWER_OFF: |
403 | 404 | kernel_power_off(); |
404 | 405 | |
405 | 406 | |
406 | 407 | |
... | ... | @@ -417,29 +418,22 @@ |
417 | 418 | |
418 | 419 | #ifdef CONFIG_KEXEC |
419 | 420 | case LINUX_REBOOT_CMD_KEXEC: |
420 | - { | |
421 | - int ret; | |
422 | - ret = kernel_kexec(); | |
423 | - unlock_kernel(); | |
424 | - return ret; | |
425 | - } | |
421 | + ret = kernel_kexec(); | |
422 | + break; | |
426 | 423 | #endif |
427 | 424 | |
428 | 425 | #ifdef CONFIG_HIBERNATION |
429 | 426 | case LINUX_REBOOT_CMD_SW_SUSPEND: |
430 | - { | |
431 | - int ret = hibernate(); | |
432 | - unlock_kernel(); | |
433 | - return ret; | |
434 | - } | |
427 | + ret = hibernate(); | |
428 | + break; | |
435 | 429 | #endif |
436 | 430 | |
437 | 431 | default: |
438 | - unlock_kernel(); | |
439 | - return -EINVAL; | |
432 | + ret = -EINVAL; | |
433 | + break; | |
440 | 434 | } |
441 | 435 | unlock_kernel(); |
442 | - return 0; | |
436 | + return ret; | |
443 | 437 | } |
444 | 438 | |
445 | 439 | static void deferred_cad(struct work_struct *dummy) |