From 90b6aec53da5a124a4422b3c0b155aa9952c642e Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Fri, 29 Mar 2019 18:05:36 +0900 Subject: [PATCH] get_one_cpu_topology: Fix error-handling Fix the error handling of the following two functions: ihk_device_get_cpu_topology: Returns NULL when not found, valid non-NULL pointer when found get_cache_topology: Returns NULL when not found, valid non-NULL pointer when found, minus error number on error Change-Id: Ied13a61d4ab0c314477c45ea659ff2b798ad97ee Fujitsu: POSTK_DEBUG_TEMP_FIX_21 --- executer/kernel/mcctrl/sysfs_files.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/executer/kernel/mcctrl/sysfs_files.c b/executer/kernel/mcctrl/sysfs_files.c index 2f096ec8..ebcb03ab 100644 --- a/executer/kernel/mcctrl/sysfs_files.c +++ b/executer/kernel/mcctrl/sysfs_files.c @@ -387,12 +387,8 @@ static struct cpu_topology *get_one_cpu_topology(struct mcctrl_usrdata *udp, topology->saved = ihk_device_get_cpu_topology(dev, mckernel_cpu_2_hw_id(udp, index)); -#ifdef POSTK_DEBUG_TEMP_FIX_21 /* IS_ERR() through return NULL */ if (!topology->saved) { -#else /* POSTK_DEBUG_TEMP_FIX_21 */ - if (IS_ERR(topology->saved)) { -#endif /* POSTK_DEBUG_TEMP_FIX_21 */ - error = PTR_ERR(topology->saved); + error = -ENOENT; eprintk("mcctrl:get_one_cpu_topology:" "ihk_device_get_cpu_topology failed. %d\n", error); @@ -428,6 +424,9 @@ static struct cpu_topology *get_one_cpu_topology(struct mcctrl_usrdata *udp, "get_cache_topology failed. %d\n", error); goto out; + } else if (!cache) { + error = -ENOENT; + goto out; } list_add(&cache->chain, &topology->cache_list);