From 4ec907c773a807d58b17f909522c27d05878b5b5 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 23 Sep 2016 18:11:16 +0200 Subject: [PATCH] ucm: fix crash when calling snd_use_case_geti() with no device or modifier When calling snd_use_case_geti(uc_mgr, "_devstatus", &lvalue) the code ends up calling device_status(uc_mgr, NULL), which result in a crash in strcmp(dev->name, NULL), when there are enabled devices. This happens because snd_use_case_geti() allows a "_devstatus" identifier even if it's only supposed to allow the form "_devstatus/{device}". So check that the device name is not null. The same issue occurs with "_modstatus", this change fixes that as well. Signed-off-by: Antonio Ospite Signed-off-by: Takashi Iwai --- src/ucm/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ucm/main.c b/src/ucm/main.c index 24d9510e..8cc92089 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -1528,12 +1528,20 @@ int snd_use_case_geti(snd_use_case_mgr_t *uc_mgr, str = NULL; } if (check_identifier(identifier, "_devstatus")) { + if (!str) { + err = -EINVAL; + goto __end; + } err = device_status(uc_mgr, str); if (err >= 0) { *value = err; err = 0; } } else if (check_identifier(identifier, "_modstatus")) { + if (!str) { + err = -EINVAL; + goto __end; + } err = modifier_status(uc_mgr, str); if (err >= 0) { *value = err; -- 2.47.1