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: <77bdb152-db01-9ad0-fc9f-a8921107a119@wanadoo.fr>
Date:   Thu, 23 Jun 2022 10:24:59 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Jianglei Nie <niejianglei2021@....com>, linux@...linux.org.uk,
        andrew@...n.ch, hkallweit1@...il.com, davem@...emloft.net,
        edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: sfp: fix memory leak in sfp_probe()

Le 23/06/2022 à 09:09, Jianglei Nie a écrit :
> sfp_probe() allocates a memory chunk from sfp with sfp_alloc(), when
> devm_add_action() fails, sfp is not freed, which leads to a memory leak.
> 
> We should free the sfp with sfp_cleanup() when devm_add_action() fails.
> 
> Signed-off-by: Jianglei Nie <niejianglei2021@....com>
> ---
>   drivers/net/phy/sfp.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 9a5d5a10560f..366a89adabf5 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -2517,8 +2517,10 @@ static int sfp_probe(struct platform_device *pdev)
>   	platform_set_drvdata(pdev, sfp);
>   
>   	err = devm_add_action(sfp->dev, sfp_cleanup, sfp);
> -	if (err < 0)
> +	if (err < 0) {
> +		sfp_cleanup(sfp);
>   		return err;
> +	}

Hi,

or use devm_add_action_or_reset() instead?

Just my 2c,

CJ

>   
>   	sff = sfp->type = &sfp_data;
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ