提交 fc589a3c 编写于 作者: H Henrique de Moraes Holschuh 提交者: Len Brown

ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers

Map an mutex_lock_interruptible() error return into ERESTARTSYS, as the
only possible error from mutex_lock_interruptible is EINTR, and that will
only happen if signal_pending() causes the mutex lock attempt to abort.

This still allows signals to be delivered ASAP, which is much nicer than
just doing mutex_lock, and still shadows userspace from EINTR when
SA_RESTART is active.

Problem reported by Peter Jordan.
Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Peter Jordan <usernetwork@gmx.info>
Cc: Richard Neill <rn214@hermes.cam.ac.uk>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 b856f5b8
...@@ -1342,9 +1342,8 @@ static int hotkey_read(char *p) ...@@ -1342,9 +1342,8 @@ static int hotkey_read(char *p)
return len; return len;
} }
res = mutex_lock_interruptible(&hotkey_mutex); if (mutex_lock_interruptible(&hotkey_mutex))
if (res < 0) return -ERESTARTSYS;
return res;
res = hotkey_get(&status, &mask); res = hotkey_get(&status, &mask);
mutex_unlock(&hotkey_mutex); mutex_unlock(&hotkey_mutex);
if (res) if (res)
...@@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf) ...@@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf)
if (!tp_features.hotkey) if (!tp_features.hotkey)
return -ENODEV; return -ENODEV;
res = mutex_lock_interruptible(&hotkey_mutex); if (mutex_lock_interruptible(&hotkey_mutex))
if (res < 0) return -ERESTARTSYS;
return res;
res = hotkey_get(&status, &mask); res = hotkey_get(&status, &mask);
if (res) if (res)
...@@ -3768,9 +3766,8 @@ static ssize_t fan_pwm1_store(struct device *dev, ...@@ -3768,9 +3766,8 @@ static ssize_t fan_pwm1_store(struct device *dev,
/* scale down from 0-255 to 0-7 */ /* scale down from 0-255 to 0-7 */
newlevel = (s >> 5) & 0x07; newlevel = (s >> 5) & 0x07;
rc = mutex_lock_interruptible(&fan_mutex); if (mutex_lock_interruptible(&fan_mutex))
if (rc < 0) return -ERESTARTSYS;
return rc;
rc = fan_get_status(&status); rc = fan_get_status(&status);
if (!rc && (status & if (!rc && (status &
...@@ -4020,9 +4017,8 @@ static int fan_get_status_safe(u8 *status) ...@@ -4020,9 +4017,8 @@ static int fan_get_status_safe(u8 *status)
int rc; int rc;
u8 s; u8 s;
rc = mutex_lock_interruptible(&fan_mutex); if (mutex_lock_interruptible(&fan_mutex))
if (rc < 0) return -ERESTARTSYS;
return rc;
rc = fan_get_status(&s); rc = fan_get_status(&s);
if (!rc) if (!rc)
fan_update_desired_level(s); fan_update_desired_level(s);
...@@ -4156,9 +4152,8 @@ static int fan_set_level_safe(int level) ...@@ -4156,9 +4152,8 @@ static int fan_set_level_safe(int level)
if (!fan_control_allowed) if (!fan_control_allowed)
return -EPERM; return -EPERM;
rc = mutex_lock_interruptible(&fan_mutex); if (mutex_lock_interruptible(&fan_mutex))
if (rc < 0) return -ERESTARTSYS;
return rc;
if (level == TPACPI_FAN_LAST_LEVEL) if (level == TPACPI_FAN_LAST_LEVEL)
level = fan_control_desired_level; level = fan_control_desired_level;
...@@ -4179,9 +4174,8 @@ static int fan_set_enable(void) ...@@ -4179,9 +4174,8 @@ static int fan_set_enable(void)
if (!fan_control_allowed) if (!fan_control_allowed)
return -EPERM; return -EPERM;
rc = mutex_lock_interruptible(&fan_mutex); if (mutex_lock_interruptible(&fan_mutex))
if (rc < 0) return -ERESTARTSYS;
return rc;
switch (fan_control_access_mode) { switch (fan_control_access_mode) {
case TPACPI_FAN_WR_ACPI_FANS: case TPACPI_FAN_WR_ACPI_FANS:
...@@ -4235,9 +4229,8 @@ static int fan_set_disable(void) ...@@ -4235,9 +4229,8 @@ static int fan_set_disable(void)
if (!fan_control_allowed) if (!fan_control_allowed)
return -EPERM; return -EPERM;
rc = mutex_lock_interruptible(&fan_mutex); if (mutex_lock_interruptible(&fan_mutex))
if (rc < 0) return -ERESTARTSYS;
return rc;
rc = 0; rc = 0;
switch (fan_control_access_mode) { switch (fan_control_access_mode) {
...@@ -4274,9 +4267,8 @@ static int fan_set_speed(int speed) ...@@ -4274,9 +4267,8 @@ static int fan_set_speed(int speed)
if (!fan_control_allowed) if (!fan_control_allowed)
return -EPERM; return -EPERM;
rc = mutex_lock_interruptible(&fan_mutex); if (mutex_lock_interruptible(&fan_mutex))
if (rc < 0) return -ERESTARTSYS;
return rc;
rc = 0; rc = 0;
switch (fan_control_access_mode) { switch (fan_control_access_mode) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册