From: Andrew Lunn <andrew@lunn.ch>
To: Xiaolei Wang <xiaolei.wang@windriver.com>
Cc: wei.fang@nxp.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, imx@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [v2 PATCH] net: fec: free fec queue when fec_probe() fails or fec_drv_remove()
Date: Thu, 23 May 2024 15:01:55 +0200 [thread overview]
Message-ID: <ca1c4de5-537a-4aa9-851d-d37ce800fdac@lunn.ch> (raw)
In-Reply-To: <20240523062920.2472432-1-xiaolei.wang@windriver.com>
On Thu, May 23, 2024 at 02:29:20PM +0800, Xiaolei Wang wrote:
> commit 59d0f7465644 ("net: fec: init multi queue date structure")
> allocates multiple queues, which should be cleaned up when fec_probe()
> fails or fec_drv_remove(), otherwise a memory leak will occur.
>
> unreferenced object 0xffffff8010350000 (size 8192):
> comm "kworker/u8:3", pid 39, jiffies 4294893562
> hex dump (first 32 bytes):
> 02 00 00 00 00 00 00 00 00 50 06 8a c0 ff ff ff .........P......
> e0 6f 06 8a c0 ff ff ff 00 50 06 8a c0 ff ff ff .o.......P......
> backtrace (crc f1b8b79f):
> [<0000000057d2c6ae>] kmemleak_alloc+0x34/0x40
> [<000000003c413e60>] kmalloc_trace+0x2f8/0x460
> [<00000000663f64e6>] fec_probe+0x1364/0x3a04
> [<0000000024d7e427>] platform_probe+0xc4/0x198
> [<00000000293aa124>] really_probe+0x17c/0x4f0
> [<00000000dfd1e0f3>] __driver_probe_device+0x158/0x2c4
>
> Fixes: 59d0f7465644 ("net: fec: init multi queue date structure")
> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Please read what i suggested. It is good to have code which is
symmetric. probe() and remove() should be opposites of each other.
probe() calls fec_enet_init(). So it would be good to have remove()
call fec_enet_deinit() which does the opposite. We then have symmetry.
Is there anything else in fec_enet_init() which needs undoing? A rule
of thumb: If you find a bug, look around, there might be others
nearby. Maybe leaking the queues is not the only problem?
Andrew
next prev parent reply other threads:[~2024-05-23 13:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 6:29 Xiaolei Wang
2024-05-23 13:01 ` Andrew Lunn [this message]
2024-05-24 1:23 ` Wei Fang
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=ca1c4de5-537a-4aa9-851d-d37ce800fdac@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shenwei.wang@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaolei.wang@windriver.com \
--cc=xiaoning.wang@nxp.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
all inboxes | Powered by JetHome®