util: device-notifier: Fix unreachable code when using unregister_notifier() 08/314808/1
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 19 Jul 2024 10:05:56 +0000 (19:05 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 19 Jul 2024 10:05:56 +0000 (19:05 +0900)
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 <cw00.choi@samsung.com>
src/util/device-notifier.c

index ab2c6bf23d3755e97df135fb34a65099d5edd501..903bd23984a2d99972eabc98252ea8538449c452 100644 (file)
@@ -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) &&