Commit 3b8ecd22 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'bkl-core-for-linus' of...

Merge branch 'bkl-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'bkl-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  sys: Remove BKL from sys_reboot
  pm_qos: clean up racy global "name" variable
  pm_qos: remove BKL
parents a9280fed 6f15fa50
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/pm_qos_params.h> #include <linux/pm_qos_params.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
...@@ -344,37 +343,33 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) ...@@ -344,37 +343,33 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)
} }
EXPORT_SYMBOL_GPL(pm_qos_remove_notifier); EXPORT_SYMBOL_GPL(pm_qos_remove_notifier);
#define PID_NAME_LEN sizeof("process_1234567890") #define PID_NAME_LEN 32
static char name[PID_NAME_LEN];
static int pm_qos_power_open(struct inode *inode, struct file *filp) static int pm_qos_power_open(struct inode *inode, struct file *filp)
{ {
int ret; int ret;
long pm_qos_class; long pm_qos_class;
char name[PID_NAME_LEN];
lock_kernel();
pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
if (pm_qos_class >= 0) { if (pm_qos_class >= 0) {
filp->private_data = (void *)pm_qos_class; filp->private_data = (void *)pm_qos_class;
sprintf(name, "process_%d", current->pid); snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
ret = pm_qos_add_requirement(pm_qos_class, name, ret = pm_qos_add_requirement(pm_qos_class, name,
PM_QOS_DEFAULT_VALUE); PM_QOS_DEFAULT_VALUE);
if (ret >= 0) { if (ret >= 0)
unlock_kernel();
return 0; return 0;
} }
}
unlock_kernel();
return -EPERM; return -EPERM;
} }
static int pm_qos_power_release(struct inode *inode, struct file *filp) static int pm_qos_power_release(struct inode *inode, struct file *filp)
{ {
int pm_qos_class; int pm_qos_class;
char name[PID_NAME_LEN];
pm_qos_class = (long)filp->private_data; pm_qos_class = (long)filp->private_data;
sprintf(name, "process_%d", current->pid); snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
pm_qos_remove_requirement(pm_qos_class, name); pm_qos_remove_requirement(pm_qos_class, name);
return 0; return 0;
...@@ -385,13 +380,14 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, ...@@ -385,13 +380,14 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
{ {
s32 value; s32 value;
int pm_qos_class; int pm_qos_class;
char name[PID_NAME_LEN];
pm_qos_class = (long)filp->private_data; pm_qos_class = (long)filp->private_data;
if (count != sizeof(s32)) if (count != sizeof(s32))
return -EINVAL; return -EINVAL;
if (copy_from_user(&value, buf, sizeof(s32))) if (copy_from_user(&value, buf, sizeof(s32)))
return -EFAULT; return -EFAULT;
sprintf(name, "process_%d", current->pid); snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
pm_qos_update_requirement(pm_qos_class, name, value); pm_qos_update_requirement(pm_qos_class, name, value);
return sizeof(s32); return sizeof(s32);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/utsname.h> #include <linux/utsname.h>
#include <linux/mman.h> #include <linux/mman.h>
#include <linux/smp_lock.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/prctl.h> #include <linux/prctl.h>
...@@ -349,6 +348,9 @@ void kernel_power_off(void) ...@@ -349,6 +348,9 @@ void kernel_power_off(void)
machine_power_off(); machine_power_off();
} }
EXPORT_SYMBOL_GPL(kernel_power_off); EXPORT_SYMBOL_GPL(kernel_power_off);
static DEFINE_MUTEX(reboot_mutex);
/* /*
* Reboot system call: for obvious reasons only root may call it, * Reboot system call: for obvious reasons only root may call it,
* and even root needs to set up some magic numbers in the registers * and even root needs to set up some magic numbers in the registers
...@@ -381,7 +383,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, ...@@ -381,7 +383,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
cmd = LINUX_REBOOT_CMD_HALT; cmd = LINUX_REBOOT_CMD_HALT;
lock_kernel(); mutex_lock(&reboot_mutex);
switch (cmd) { switch (cmd) {
case LINUX_REBOOT_CMD_RESTART: case LINUX_REBOOT_CMD_RESTART:
kernel_restart(NULL); kernel_restart(NULL);
...@@ -397,20 +399,18 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, ...@@ -397,20 +399,18 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
case LINUX_REBOOT_CMD_HALT: case LINUX_REBOOT_CMD_HALT:
kernel_halt(); kernel_halt();
unlock_kernel();
do_exit(0); do_exit(0);
panic("cannot halt"); panic("cannot halt");
case LINUX_REBOOT_CMD_POWER_OFF: case LINUX_REBOOT_CMD_POWER_OFF:
kernel_power_off(); kernel_power_off();
unlock_kernel();
do_exit(0); do_exit(0);
break; break;
case LINUX_REBOOT_CMD_RESTART2: case LINUX_REBOOT_CMD_RESTART2:
if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) { if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) {
unlock_kernel(); ret = -EFAULT;
return -EFAULT; break;
} }
buffer[sizeof(buffer) - 1] = '\0'; buffer[sizeof(buffer) - 1] = '\0';
...@@ -433,7 +433,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, ...@@ -433,7 +433,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
unlock_kernel(); mutex_unlock(&reboot_mutex);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment