History

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.

Andi Kleen committed 17 years ago

Commit 3d26dcf1 parent 4cafbd01 file · +9 −15Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/sys.c+9−15
@@ -360,6 +360,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, · 359 unmodified lines
360360 void __user *, arg)
361361 {
362362 char buffer[256];
363+ int ret = 0;
363364
364365 /* We only trust the superuser with rebooting the system. */
365366 if (!capable(CAP_SYS_BOOT))
@@ -397,7 +398,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, · 31 unmodified lines
397398 kernel_halt();
398399 unlock_kernel();
399400 do_exit(0);
400− break;
401+ panic("cannot halt");
401402
402403 case LINUX_REBOOT_CMD_POWER_OFF:
403404 kernel_power_off();
@@ -417,29 +418,22 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, · 13 unmodified lines
417418
418419 #ifdef CONFIG_KEXEC
419420 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;
426423 #endif
427424
428425 #ifdef CONFIG_HIBERNATION
429426 case LINUX_REBOOT_CMD_SW_SUSPEND:
430− {
431− int ret = hibernate();
432− unlock_kernel();
433− return ret;
434− }
427+ ret = hibernate();
428+ break;
435429 #endif
436430
437431 default:
438− unlock_kernel();
439− return -EINVAL;
432+ ret = -EINVAL;
433+ break;
440434 }
441435 unlock_kernel();
442− return 0;
436+ return ret;
443437 }
444438
445439 static void deferred_cad(struct work_struct *dummy)