[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <45265aca-7371-455f-819f-c4d68cbb089b@web.de>
Date: Thu, 24 Oct 2024 14:02:45 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: Daniel Lezcano <daniel.lezcano@...aro.org>, linux-pm@...r.kernel.org,
Lukasz Luba <lukasz.luba@....com>, "Rafael J. Wysocki" <rafael@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>, Zhang Rui <rui.zhang@...el.com>
Subject: Re: [PATCH] thermal/lib: Fix memory leak on error in
thermal_genl_auto()
> The function thermal_genl_auto() does not free the allocated message
> in the error path. Fix that by putting a out label and jump to it
> which will free the message instead of directly returning an error.
Would you like to add any tags (like “Fixes” and “Cc”) accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc4#n145
…
> +++ b/tools/lib/thermal/commands.c
> @@ -375,27 +375,30 @@ static thermal_error_t thermal_genl_auto(struct thermal_handler *th, cmd_cb_t cm
> struct cmd_param *param,
> int cmd, int flags, void *arg)
> {
> + thermal_error_t ret = THERMAL_ERROR;
> struct nl_msg *msg;
> void *hdr;
>
> msg = nlmsg_alloc();
> if (!msg)
> - return THERMAL_ERROR;
> + goto out;
…
Is it really reasonable to pass a null pointer (from a failed function call)
to a subsequent nlmsg_free() call?
Can it be more appropriate to return directly in such an error case?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.12-rc4#n532
Regards,
Markus
Powered by blists - more mailing lists