Re: [PATCH AUTOSEL 5.10 1/6] pm: cpupower: bench: Prevent NULL dereference on malloc failure
From: Pavel Machek
Date: Fri Apr 18 2025 - 12:53:34 EST
Hi!
> [ Upstream commit 208baa3ec9043a664d9acfb8174b332e6b17fb69 ]
>
> If malloc returns NULL due to low memory, 'config' pointer can be NULL.
> Add a check to prevent NULL dereference.
This fixes nothing. We have oom killer, so we don't have malloc
returning NULL.
Best regards,
Pavel
> +++ b/tools/power/cpupower/bench/parse.c
> @@ -120,6 +120,10 @@ FILE *prepare_output(const char *dirname)
> struct config *prepare_default_config()
> {
> struct config *config = malloc(sizeof(struct config));
> + if (!config) {
> + perror("malloc");
> + return NULL;
> + }
>
> dprintf("loading defaults\n");
>
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Attachment:
signature.asc
Description: PGP signature