netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taehee Yoo <ap420073@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@google.com, ecree.xilinx@gmail.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH net 2/2] net: sfc: siena: fix memory leak in siena_mtd_probe()
Date: Wed, 11 May 2022 17:14:06 +0900	[thread overview]
Message-ID: <9888e938-f987-79b2-2a27-89674baaef6c@gmail.com> (raw)
In-Reply-To: <20220511062503.s7ndwcvzxzkyyniq@gmail.com>

2022. 5. 11. 오후 3:25에 Martin Habets 이(가) 쓴 글:

Hi Martin,
Thanks a lot for your review!

 > 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.
 >

Okay, I will send a v2 patch tomorrow, that will drop this patch and 
unnecessary cover-letter.

Thanks!
Taehee Yoo

 > 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@gmail.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

      reply	other threads:[~2022-05-11  8:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 15:36 [PATCH net 0/2] net: sfc: fix memory leak in ->mtd_probe() callback Taehee Yoo
2022-05-10 15:36 ` [PATCH net 1/2] net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe() Taehee Yoo
2022-05-11  6:09   ` Martin Habets
2022-05-10 15:36 ` [PATCH net 2/2] net: sfc: siena: fix memory leak in siena_mtd_probe() Taehee Yoo
2022-05-11  6:25   ` Martin Habets
2022-05-11  8:14     ` Taehee Yoo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9888e938-f987-79b2-2a27-89674baaef6c@gmail.com \
    --to=ap420073@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).