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] [day] [month] [year] [list]
Message-ID: <CAMRc=Md5+pSxx3kxhrYpt_oMUOCUkzxeWEy=YXnhY_4053gqRA@mail.gmail.com>
Date: Thu, 26 Jun 2025 10:25:23 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Gabor Juhos <j4g8y7@...il.com>
Cc: Georgi Djakov <djakov@...nel.org>, Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, 
	Dmitry Baryshkov <lumag@...nel.org>, linux-pm@...r.kernel.org, linux-arm-msm@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] interconnect: icc-clk: destroy nodes in case of memory
 allocation failures

On Wed, Jun 25, 2025 at 7:32 PM Gabor Juhos <j4g8y7@...il.com> wrote:
>
> When memory allocation fails during creating the name of the nodes in
> icc_clk_register(), the code continues on the error path and it calls
> icc_nodes_remove() to destroy the already created nodes. However that
> function only destroys the nodes which were already added to the provider
> and the newly created nodes are never destroyed in case of error.
>
> In order to avoid a memory leaks, change the code to destroy the newly
> created nodes explicitly in case of memory allocation failures.
>
> Fixes: 44c5aa73ccd1 ("interconnect: icc-clk: check return values of devm_kasprintf()")
> Signed-off-by: Gabor Juhos <j4g8y7@...il.com>
> ---
>  drivers/interconnect/icc-clk.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/interconnect/icc-clk.c b/drivers/interconnect/icc-clk.c
> index 88f311c110207757f0609e5cec7d377a91133c6d..93c030608d3e0aad7d9c1ed81a51dcde0d3f85ab 100644
> --- a/drivers/interconnect/icc-clk.c
> +++ b/drivers/interconnect/icc-clk.c
> @@ -117,6 +117,7 @@ struct icc_provider *icc_clk_register(struct device *dev,
>
>                 node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_master", data[i].name);
>                 if (!node->name) {
> +                       icc_node_destroy(node->id);
>                         ret = -ENOMEM;
>                         goto err;
>                 }
> @@ -135,6 +136,7 @@ struct icc_provider *icc_clk_register(struct device *dev,
>
>                 node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_slave", data[i].name);
>                 if (!node->name) {
> +                       icc_node_destroy(node->id);
>                         ret = -ENOMEM;
>                         goto err;
>                 }
>
> ---
> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
> change-id: 20250625-icc-clk-memleak-fix-4462b5153970
>
> Best regards,
> --
> Gabor Juhos <j4g8y7@...il.com>
>
>

Thanks for catching this.

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ