diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-05 05:12:50 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-05 05:12:50 +0000 |
commit | 20ead21996b66817d0e095e313658fbd5d35dc42 (patch) | |
tree | 6840bcd6f1f57f41e48bc4cc255920283a5b33b8 /sys/dev/acpi/acpithinkpad.c | |
parent | 34287a5c23e9b3e4e0ece8d1f68b51d7680e7dc7 (diff) |
Return ENOTTY in acpithinkpad backlight get/set ioctls if the maximum
value is 0 to match the behaviour when the callbacks are not set.
Prevents a divide by zero in wsconsctl(8) reported by Caspar Schutijser.
earlier version ok jung@ deraadt@ kettenis@
Diffstat (limited to 'sys/dev/acpi/acpithinkpad.c')
-rw-r--r-- | sys/dev/acpi/acpithinkpad.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/acpi/acpithinkpad.c b/sys/dev/acpi/acpithinkpad.c index 35388388ab2..04731bbc3e3 100644 --- a/sys/dev/acpi/acpithinkpad.c +++ b/sys/dev/acpi/acpithinkpad.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpithinkpad.c,v 1.51 2016/01/10 16:30:43 stsp Exp $ */ +/* $OpenBSD: acpithinkpad.c,v 1.52 2016/05/05 05:12:49 jsg Exp $ */ /* * Copyright (c) 2008 joshua stein <jcs@openbsd.org> * @@ -631,6 +631,10 @@ thinkpad_get_backlight(struct wskbd_backlight *kbl) kbl->min = 0; kbl->max = (sc->sc_thinklight >> 8) & 0x0f; kbl->curval = sc->sc_thinklight & 0x0f; + + if (kbl->max == 0) + return (ENOTTY); + return 0; } @@ -642,6 +646,9 @@ thinkpad_set_backlight(struct wskbd_backlight *kbl) KASSERT(sc != NULL); + if (maxval == 0) + return (ENOTTY); + if (kbl->curval > maxval) return EINVAL; |