resource: system: Fix to check NULL for private data 27/280227/1
authorDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 25 Aug 2022 04:44:44 +0000 (13:44 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 25 Aug 2022 10:53:10 +0000 (19:53 +0900)
Change-Id: I70cb0cfd108ec165d8a863cf6c4c35ea42571b69
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/resource/resource-system.c

index cc2b8a6..42c7d43 100644 (file)
@@ -306,10 +306,14 @@ static void system_delete(struct resource *res)
 
 static int system_driver_prepare_update(struct resource *res)
 {
-       struct system_resource_data *sysdata = get_resource_privdata(res);
+       struct system_resource_data *sysdata;
        const char *res_name = get_resource_name(res);
        int ret;
 
+       sysdata = get_resource_privdata(res);
+       if (!sysdata)
+               return -EINVAL;
+
        /* Get the per-cpu utilization */
        memcpy(sysdata->prev_cpus, sysdata->curr_cpus,
                        sizeof(struct cpu_stat) * sysdata->num_possible_cpus);