util: kernel: Check for returned value is NULL in kernel_get_process_taskstats() 04/317804/1 accepted/tizen_unified_dev accepted/tizen_unified_toolchain accepted/tizen/9.0/unified/20241030.235945 accepted/tizen/unified/20240919.163750 accepted/tizen/unified/dev/20240920.060431 accepted/tizen/unified/toolchain/20241004.102105 accepted/tizen/unified/x/20240920.053204 accepted/tizen/unified/x/asan/20241014.000510 tizen_9.0_m2_release
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 19 Sep 2024 01:39:37 +0000 (10:39 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 19 Sep 2024 01:42:27 +0000 (10:42 +0900)
Change-Id: I0dba6c77957722aed371b5dd1551454f144d2ca1
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/util/kernel.c

index 6259968b231ca30aeb270aaf53b4e3766cc4cf0c..e3dedda80afd536ca96eb14fa95c75303167eab4 100644 (file)
@@ -343,7 +343,14 @@ int kernel_get_process_taskstats(struct taskstats *stats, int cmd_type, pid_t pi
        if (ret < 0)
                goto err_genl_close;
 
-       cb = nl_cb_get(nl_cb_alloc(NL_CB_CUSTOM));
+       cb = nl_cb_alloc(NL_CB_CUSTOM);
+       if (!cb)
+               return -ENOMEM;
+
+       cb = nl_cb_get(cb);
+       if (!cb)
+               return -EINVAL;
+
        nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, &parse_task_stats, stats);
        nl_cb_err(cb, NL_CB_CUSTOM, &print_receive_error, NULL);