alsactl: init - set_ctl_value() - fix bytes parsing

Use the correct error value handling from hextodigit().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-01-08 18:15:43 +01:00
parent 42ca978078
commit e55534d8a5

View file

@ -465,12 +465,13 @@ static int set_ctl_value(struct space *space, const char *value, int all)
return -EINVAL;
}
for (idx = 0; idx < count; idx += 2) {
val = hextodigit(*(value++)) << 4;
val |= hextodigit(*(value++));
if (val > 255) {
int nibble1 = hextodigit(*(value++));
int nibble2 = hextodigit(*(value++));
if (nibble1 < 0 || nibble2 < 0) {
Perror(space, "bad ctl hexa value");
return -EINVAL;
}
val = (nibble1 << 4) | nibble2;
snd_ctl_elem_value_set_byte(space->ctl_value, idx, val);
}
break;