From: Andi Kleen <andi@firstfloor.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Clean up sys_shutdown
Date: Wed, 8 Apr 2009 00:36:26 +0200 [thread overview]
Message-ID: <20090407223626.GA25557@basil.nowhere.org> (raw)
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>
---
kernel/sys.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
Index: linux/kernel/sys.c
===================================================================
--- linux.orig/kernel/sys.c 2009-04-07 16:09:58.000000000 +0200
+++ linux/kernel/sys.c 2009-04-07 16:43:17.000000000 +0200
@@ -360,6 +360,7 @@
void __user *, arg)
{
char buffer[256];
+ int ret = 0;
/* We only trust the superuser with rebooting the system. */
if (!capable(CAP_SYS_BOOT))
@@ -397,7 +398,7 @@
kernel_halt();
unlock_kernel();
do_exit(0);
- break;
+ panic("cannot halt");
case LINUX_REBOOT_CMD_POWER_OFF:
kernel_power_off();
@@ -417,29 +418,22 @@
#ifdef CONFIG_KEXEC
case LINUX_REBOOT_CMD_KEXEC:
- {
- int ret;
- ret = kernel_kexec();
- unlock_kernel();
- return ret;
- }
+ ret = kernel_kexec();
+ break;
#endif
#ifdef CONFIG_HIBERNATION
case LINUX_REBOOT_CMD_SW_SUSPEND:
- {
- int ret = hibernate();
- unlock_kernel();
- return ret;
- }
+ ret = hibernate();
+ break;
#endif
default:
- unlock_kernel();
- return -EINVAL;
+ ret = -EINVAL;
+ break;
}
unlock_kernel();
- return 0;
+ return ret;
}
static void deferred_cad(struct work_struct *dummy)
next reply other threads:[~2009-04-07 22:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 22:36 Andi Kleen [this message]
2009-04-10 5:14 ` [PATCH] Clean up sys_shutdown Andrew Morton
2009-04-10 8:38 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090407223626.GA25557@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox