From 49068421110985fc99162a7e37df6111e205e606 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 19 Jul 2024 19:05:56 +0900 Subject: [PATCH] util: device-notifier: Fix unreachable code when using unregister_notifier() Fix unreachable code when using unregister_notifier() by returning the error code if failed. Before this patch, the usage code of unregister_notifier() is not able to receive the any error code. Change-Id: I1bf9575a05b8dd2ca1c47e26e063dc90dbf892e0 Signed-off-by: Chanwoo Choi --- src/util/device-notifier.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/device-notifier.c b/src/util/device-notifier.c index ab2c6bf..903bd23 100644 --- a/src/util/device-notifier.c +++ b/src/util/device-notifier.c @@ -78,6 +78,9 @@ int unregister_notifier(enum device_notifier_type status, GList *n; struct device_notifier *notifier; + if (status >= DEVICE_NOTIFIER_MAX || !func) + return -EINVAL; + for (n = device_notifier_list; n != NULL; n = n->next) { notifier = n->data; if ((notifier->status == status) && -- 2.34.1