pass: parser: Fix uninitialized value of number_of_cpus property 68/263168/3
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 27 Aug 2021 06:35:02 +0000 (15:35 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 27 Aug 2021 06:49:11 +0000 (15:49 +0900)
If json configuraiton file doesn't contain the 'number_of_cpus'
property, number_of_cpus has the minus value. It causes the problem.
So that fix uninitialized value of number_of_cpus property when value is
out of range.

Change-Id: Ibac93e89b3cd85181287773b0bf0cf7f4aa6f692
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-parser.c

index b772276efe9428f71f35ef6a3fe9ca30db617497..8b14c0158f8e7742e3ae6444a524c8d08ad3a15e 100644 (file)
@@ -747,6 +747,8 @@ static int parse_resource_data(struct pass *pass, int id, json_object *obj)
                break;
        }
 
+       number_of_cpus = number_of_cpus < 0 ? 0 : number_of_cpus;
+
        /* Initialize config_data from property values of confiugartion file */
        if (!strncmp(device_type, PASS_RESOURCE_CPU_NAME, strlen(device_type)))
                config_data->res_type = PASS_RESOURCE_CPU_ID;