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: <20260206-neurosis-partner-009242f0ac16@spud>
Date: Fri, 6 Feb 2026 19:52:15 +0000
From: Conor Dooley <conor@...nel.org>
To: Felix Gu <ustc.gu@...il.com>
Cc: Conor Dooley <conor.dooley@...rochip.com>,
	Daire McNamara <daire.mcnamara@...rochip.com>,
	linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] soc: microchip: mpfs: Fix a memory leak in
 mpfs_sys_controller_probe()

On Tue, Feb 03, 2026 at 09:03:52PM +0800, Felix Gu wrote:
> In mpfs_sys_controller_probe(), when of_get_mtd_device_by_node() fails,
> the previously allocated sys_controller was leaked.
> 
> Add kfree() to fix this.
> 
> Fixes: 742aa6c563d2 ("soc: microchip: mpfs: enable access to the system controller's flash")
> Signed-off-by: Felix Gu <ustc.gu@...il.com>
> ---
>  drivers/soc/microchip/mpfs-sys-controller.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/microchip/mpfs-sys-controller.c b/drivers/soc/microchip/mpfs-sys-controller.c
> index 30bc45d17d34..a7401cb79e97 100644
> --- a/drivers/soc/microchip/mpfs-sys-controller.c
> +++ b/drivers/soc/microchip/mpfs-sys-controller.c
> @@ -142,8 +142,11 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev)
>  
>  	sys_controller->flash = of_get_mtd_device_by_node(np);
>  	of_node_put(np);
> -	if (IS_ERR(sys_controller->flash))
> -		return dev_err_probe(dev, PTR_ERR(sys_controller->flash), "Failed to get flash\n");
> +	if (IS_ERR(sys_controller->flash)) {
> +		ret = dev_err_probe(dev, PTR_ERR(sys_controller->flash), "Failed to get flash\n");
> +		kfree(sys_controller);
> +		return ret;
> +	}
>  
>  no_flash:
>  	sys_controller->client.dev = dev;

This is a duplicate of a patch in my riscv-soc-fixes branch, that for
whatever reason I forgot to push. I'll keep the original but thanks for
your patch.

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ