lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0gHGrRn0cLvsSTaX=tX8mVhxudoJ4aSh5jWNxh171oKgg@mail.gmail.com>
Date: Fri, 8 Nov 2024 13:09:05 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: zhangjiao2 <zhangjiao2@...s.chinamobile.com>
Cc: rafael@...nel.org, daniel.lezcano@...aro.org, rui.zhang@...el.com, 
	lukasz.luba@....com, linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tools/thermal: Fix common realloc mistake

On Fri, Nov 8, 2024 at 7:39 AM zhangjiao2
<zhangjiao2@...s.chinamobile.com> wrote:
>
> From: zhang jiao <zhangjiao2@...s.chinamobile.com>
>
> Do not set thermometer->tz NULL when realloc failed.

Presumably, this fixes a problem.

What problem does it fix?

> Signed-off-by: zhang jiao <zhangjiao2@...s.chinamobile.com>
> ---
>  tools/thermal/thermometer/thermometer.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/thermal/thermometer/thermometer.c b/tools/thermal/thermometer/thermometer.c
> index 1a87a0a77f9f..e08291a97fd8 100644
> --- a/tools/thermal/thermometer/thermometer.c
> +++ b/tools/thermal/thermometer/thermometer.c
> @@ -259,6 +259,7 @@ static int thermometer_add_tz(const char *path, const char *name, int polling,
>  {
>         int fd;
>         char tz_path[PATH_MAX];
> +       void *tmp;
>
>         sprintf(tz_path, CLASS_THERMAL"/%s/temp", path);
>
> @@ -268,12 +269,13 @@ static int thermometer_add_tz(const char *path, const char *name, int polling,
>                 return -1;
>         }
>
> -       thermometer->tz = realloc(thermometer->tz,
> +       tmp = realloc(thermometer->tz,
>                                   sizeof(*thermometer->tz) * (thermometer->nr_tz + 1));
> -       if (!thermometer->tz) {
> +       if (!tmp) {
>                 ERROR("Failed to allocate thermometer->tz\n");
>                 return -1;
>         }
> +       thermometer->tz = tmp;
>
>         thermometer->tz[thermometer->nr_tz].fd_temp = fd;
>         thermometer->tz[thermometer->nr_tz].name = strdup(name);
> --
> 2.33.0
>
>
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ