mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-05 08:48:05 +02:00
up-input.c: fix bitmap check
In up_input_coldplug(), some checks are done on the input device found in order
to detect if it's a lid switch or not.
The following one is problematic :
/* convert to a bitmask */
num_bits = up_input_str_to_bitmask (contents, bitmask, sizeof (bitmask));
if (num_bits != 1) {
g_debug ("not one bitmask entry for %s", native_path);
ret = FALSE;
goto out;
}
Checking if there's only 1 bit set is wrong. It's nice if you have a x86 with
acpi using 1 input device for the lid switch but it's not always nice.
One can create input devices with gpios-keys like this:
static struct gpio_keys_button keys[] = {
{
.code = SW_LID,
.gpio = ...,
.type = EV_SW,
.desc = "Lid Switch",
},
{
.code = SW_RFKILL_ALL,
.gpio = ...,
.type = EV_SW,
.desc = "rfkill",
},
};
The resulting SW bitmap will be 9 and thus there are 2 bits sets and due to the
mentionned check, the device is ignored by upower.
As a fix, I'm checking if the number of bits is between 0 and SW_CNT
bits.
Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Richard Hughes <richard@hughsie.com>
This commit is contained in:
parent
38199e44ff
commit
8b9ee53133
1 changed files with 2 additions and 2 deletions
|
|
@ -197,8 +197,8 @@ up_input_coldplug (UpInput *input, UpDaemon *daemon, GUdevDevice *d)
|
|||
|
||||
/* convert to a bitmask */
|
||||
num_bits = up_input_str_to_bitmask (contents, bitmask, sizeof (bitmask));
|
||||
if (num_bits != 1) {
|
||||
g_debug ("not one bitmask entry for %s", native_path);
|
||||
if ((num_bits == 0) || (num_bits >= SW_CNT)) {
|
||||
g_debug ("invalid bitmask entry for %s", native_path);
|
||||
ret = FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue