From 9e0cdc10a93848567cf82e3ac7fa28fde97720e9 Mon Sep 17 00:00:00 2001 From: Pin-chih Lin Date: Tue, 2 Mar 2021 16:31:18 +0800 Subject: CRAS: check ucm manager exists before noise cancellation functions The variable ucm could be NULL for alsa_io if there is no UCM config for the device. We should check if it exists before usage, e.g. the noise cancellation set/check which we recently added. BUG=b:181329545 TEST=Check USB Headset play/record is worked on Caroline Change-Id: I3c46615902ca8e074a74b7bc03da36b85c035f69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2728905 Reviewed-by: Cheng-Yi Chiang Reviewed-by: Yu-Hsuan Hsu Commit-Queue: Pin-chih Lin Tested-by: Pin-chih Lin Auto-Submit: Pin-chih Lin --- cras/src/server/cras_alsa_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cras/src/server/cras_alsa_io.c b/cras/src/server/cras_alsa_io.c index 32b22247..275a6810 100644 --- a/cras/src/server/cras_alsa_io.c +++ b/cras/src/server/cras_alsa_io.c @@ -414,7 +414,7 @@ static int open_dev(struct cras_iodev *iodev) aio->handle = handle; /* Enable or disable noise cancellation if it supports. */ - if (iodev->direction == CRAS_STREAM_INPUT && + if (aio->ucm && iodev->direction == CRAS_STREAM_INPUT && ucm_node_noise_cancellation_exists(aio->ucm, iodev->active_node->name)) { enable_noise_cancellation = @@ -2039,7 +2039,7 @@ static int support_noise_cancellation(const struct cras_iodev *iodev) { struct alsa_io *aio = (struct alsa_io *)iodev; - if (!iodev->active_node) + if (!aio->ucm || !iodev->active_node) return 0; return ucm_node_noise_cancellation_exists(aio->ucm, -- cgit v1.2.3