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: <87lf0pmf55.fsf@mpe.ellerman.id.au>
Date:   Mon, 13 Dec 2021 13:07:18 +1100
From:   Michael Ellerman <mpe@...erman.id.au>
To:     xkernel <xkernel.wang@...mail.com>, agust@...x.de
Cc:     benh@...nel.crashing.org, paulus@...ba.org,
        linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        xkernel <xkernel.wang@...mail.com>
Subject: Re: [PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak

xkernel <xkernel.wang@...mail.com> writes:
> When some internal memory errors happend in of_iomap(), we should free
> gpt to prevent memory leak.

But it's allocated with devm_kzalloc(), so the devres core is meant to
free it for us isn't it?

cheers

> diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
> index f862b48..c506cfd 100644
> --- a/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
> +++ b/arch/powerpc/platforms/52xx/mpc52xx_gpt.c
> @@ -722,8 +722,10 @@ static int mpc52xx_gpt_probe(struct platform_device *ofdev)
>  	gpt->dev = &ofdev->dev;
>  	gpt->ipb_freq = mpc5xxx_get_bus_frequency(ofdev->dev.of_node);
>  	gpt->regs = of_iomap(ofdev->dev.of_node, 0);
> -	if (!gpt->regs)
> +	if (!gpt->regs) {
> +		devm_kfree(&ofdev->dev, gpt);
>  		return -ENOMEM;
> +	}
>  
>  	dev_set_drvdata(&ofdev->dev, gpt);
>  
> -- 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ