Skip to content

Commit

Permalink
cpupower: Fix NULL but dereferenced coccicheck errors
Browse files Browse the repository at this point in the history
Fix NULL but dereferenced coccicheck errors found by:

make coccicheck MODE=report M=tools/power/cpupower

tools/power/cpupower/lib/cpufreq.c:384:19-23: ERROR: first is NULL but dereferenced.
tools/power/cpupower/lib/cpufreq.c:440:19-23: ERROR: first is NULL but dereferenced.
tools/power/cpupower/lib/cpufreq.c:308:19-23: ERROR: first is NULL but dereferenced.
tools/power/cpupower/lib/cpufreq.c:753:19-23: ERROR: first is NULL but dereferenced.

Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
shuahkh committed Jul 6, 2020
1 parent 8e02270 commit cbf2527
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tools/power/cpupower/lib/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ struct cpufreq_available_governors *cpufreq_get_available_governors(unsigned
} else {
first = malloc(sizeof(*first));
if (!first)
goto error_out;
return NULL;
current = first;
}
current->first = first;
Expand Down Expand Up @@ -362,7 +362,7 @@ struct cpufreq_available_frequencies
} else {
first = malloc(sizeof(*first));
if (!first)
goto error_out;
return NULL;
current = first;
}
current->first = first;
Expand Down Expand Up @@ -418,7 +418,7 @@ struct cpufreq_available_frequencies
} else {
first = malloc(sizeof(*first));
if (!first)
goto error_out;
return NULL;
current = first;
}
current->first = first;
Expand Down Expand Up @@ -493,7 +493,7 @@ static struct cpufreq_affected_cpus *sysfs_get_cpu_list(unsigned int cpu,
} else {
first = malloc(sizeof(*first));
if (!first)
goto error_out;
return NULL;
current = first;
}
current->first = first;
Expand Down Expand Up @@ -726,7 +726,7 @@ struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu,
} else {
first = malloc(sizeof(*first));
if (!first)
goto error_out;
return NULL;
current = first;
}
current->first = first;
Expand Down

0 comments on commit cbf2527

Please sign in to comment.