util: resource: Check whether interest_mask is valid or not 17/278517/4
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 21 Jul 2022 09:58:45 +0000 (18:58 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Sun, 7 Aug 2022 20:32:13 +0000 (05:32 +0900)
unset_resource_attr_interest function is able to unset
the resource interest state when resource interest were already
interested. If wrong interest_mask is used, should return fail.
So that Check whether interest_mask is valid or not
before unsetting resource attribute interest.

Change-Id: I047a30ab1fa5c0cafd23327a7fbfabc9c3c9b274
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/util/resource.c

index 52cb8c1557f85a209beb0d603caa5b66154d83be..b71e67fc70a1035ebd53b59481856a52655ea819 100644 (file)
@@ -1009,6 +1009,9 @@ int unset_resource_attr_interest(struct resource *resource, u_int64_t interest_m
        if (!resource)
                return -EINVAL;
 
+       if (!is_resource_attr_interested(resource, interest_mask))
+               return -EINVAL;
+
        for (i = 0; i < resource->num_attrs; i++) {
                if (!(resource->attrs[i].id & interest_mask))
                        continue;