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: <20220511062503.s7ndwcvzxzkyyniq@gmail.com>
Date:   Wed, 11 May 2022 07:25:03 +0100
From:   Martin Habets <habetsm.xilinx@...il.com>
To:     Taehee Yoo <ap420073@...il.com>
Cc:     davem@...emloft.net, kuba@...nel.org, pabeni@...hat.com,
        edumazet@...gle.com, ecree.xilinx@...il.com, netdev@...r.kernel.org
Subject: Re: [PATCH net 2/2] net: sfc: siena: fix memory leak in
 siena_mtd_probe()

On Tue, May 10, 2022 at 03:36:19PM +0000, Taehee Yoo wrote:
> In the NIC ->probe callback, ->mtd_probe() callback is called.
> If NIC has 2 ports, ->probe() is called twice and ->mtd_probe() too.
> In the ->mtd_probe(), which is siena_mtd_probe() it allocates and
> initializes mtd partiion.
> But mtd partition for sfc is shared data.
> So that allocated mtd partition data from last called
> siena_mtd_probe() will not be used.

On Siena the 2nd port does have MTD partitions. In the output
from /proc/mtd below eth3 is the 1st port and eth4 is the 2nd
port:

mtd12: 00030000 00010000 "eth3 sfc_mcfw:0b"
mtd13: 00010000 00010000 "eth3 sfc_dynamic_cfg:00"
mtd14: 00030000 00010000 "eth3 sfc_exp_rom:01"
mtd15: 00010000 00010000 "eth3 sfc_exp_rom_cfg:00"
mtd16: 00120000 00010000 "eth3 sfc_fpga:01"
mtd17: 00010000 00010000 "eth4 sfc_dynamic_cfg:00"
mtd18: 00010000 00010000 "eth4 sfc_exp_rom_cfg:00"

So this patch is not needed, and efx_mtd_remove() will free
the memory for both ports.

Martin

> Therefore it must be freed.
> But it doesn't free a not used mtd partition data in siena_mtd_probe().
> 
> Fixes: 8880f4ec21e6 ("sfc: Add support for SFC9000 family (2)")
> Signed-off-by: Taehee Yoo <ap420073@...il.com>
> ---
>  drivers/net/ethernet/sfc/siena.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c
> index ce3060e15b54..8b42951e34d6 100644
> --- a/drivers/net/ethernet/sfc/siena.c
> +++ b/drivers/net/ethernet/sfc/siena.c
> @@ -939,6 +939,11 @@ static int siena_mtd_probe(struct efx_nic *efx)
>  		nvram_types >>= 1;
>  	}
>  
> +	if (!n_parts) {
> +		kfree(parts);
> +		return 0;
> +	}
> +
>  	rc = siena_mtd_get_fw_subtypes(efx, parts, n_parts);
>  	if (rc)
>  		goto fail;
> -- 
> 2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ