diff options
author | 2025-02-19 20:27:15 +0800 | |
---|---|---|
committer | 2025-02-19 13:48:08 -0700 | |
commit | 208baa3ec9043a664d9acfb8174b332e6b17fb69 (patch) | |
tree | ba2a120607d62152e75c8e36aa760c7110a2dc59 | |
parent | Linux 6.14-rc2 (diff) | |
download | wireguard-linux-208baa3ec9043a664d9acfb8174b332e6b17fb69.tar.xz wireguard-linux-208baa3ec9043a664d9acfb8174b332e6b17fb69.zip |
pm: cpupower: bench: Prevent NULL dereference on malloc failure
If malloc returns NULL due to low memory, 'config' pointer can be NULL.
Add a check to prevent NULL dereference.
Link: https://lore.kernel.org/r/20250219122715.3892223-1-quic_zhonhan@quicinc.com
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
-rw-r--r-- | tools/power/cpupower/bench/parse.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c index 080678d9d74e..bd67c758b33a 100644 --- a/tools/power/cpupower/bench/parse.c +++ b/tools/power/cpupower/bench/parse.c @@ -121,6 +121,10 @@ out_dir: struct config *prepare_default_config() { struct config *config = malloc(sizeof(struct config)); + if (!config) { + perror("malloc"); + return NULL; + } dprintf("loading defaults\n"); |