Skip to content

Commit cbf2527

Browse files
committed
cpupower: Fix NULL but dereferenced coccicheck errors
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]>
1 parent 8e02270 commit cbf2527

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/power/cpupower/lib/cpufreq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ struct cpufreq_available_governors *cpufreq_get_available_governors(unsigned
285285
} else {
286286
first = malloc(sizeof(*first));
287287
if (!first)
288-
goto error_out;
288+
return NULL;
289289
current = first;
290290
}
291291
current->first = first;
@@ -362,7 +362,7 @@ struct cpufreq_available_frequencies
362362
} else {
363363
first = malloc(sizeof(*first));
364364
if (!first)
365-
goto error_out;
365+
return NULL;
366366
current = first;
367367
}
368368
current->first = first;
@@ -418,7 +418,7 @@ struct cpufreq_available_frequencies
418418
} else {
419419
first = malloc(sizeof(*first));
420420
if (!first)
421-
goto error_out;
421+
return NULL;
422422
current = first;
423423
}
424424
current->first = first;
@@ -493,7 +493,7 @@ static struct cpufreq_affected_cpus *sysfs_get_cpu_list(unsigned int cpu,
493493
} else {
494494
first = malloc(sizeof(*first));
495495
if (!first)
496-
goto error_out;
496+
return NULL;
497497
current = first;
498498
}
499499
current->first = first;
@@ -726,7 +726,7 @@ struct cpufreq_stats *cpufreq_get_stats(unsigned int cpu,
726726
} else {
727727
first = malloc(sizeof(*first));
728728
if (!first)
729-
goto error_out;
729+
return NULL;
730730
current = first;
731731
}
732732
current->first = first;

0 commit comments

Comments
 (0)