From: sashiko-bot@kernel.org
To: "Markus Elfring" <Markus.Elfring@web.de>, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH] net: allwinner: Use devm_clk_get_enabled() in emac_probe()
Date: Wed, 25 Nov 2026 17:22:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-233833@kernel.org> (raw)
In-Reply-To: <780975ed-825f-4f9b-8ac2-67664a7a2a2f@web.de>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] net: sun4i-emac: use-after-free in emac_remove() [1]
--
commit c91169d2a4aeb95968164b2a476fe9e5315cf021
Author: Markus Elfring <elfring@users.sourceforge.net>
net: allwinner: Use devm_clk_get_enabled() in emac_probe()
This commit replaces devm_clk_get() and clk_prepare_enable() with
devm_clk_get_enabled() in emac_probe() and drops the explicit
clk_disable_unprepare() calls from the error path and emac_remove().
> diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
> index d7ee42b2c1976..c075356cf6ccd 100644
> --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
> +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
[ ... ]
> @@ -1093,7 +1085,6 @@ static void emac_remove(struct platform_device *pdev)
> unregister_netdev(ndev);
> of_node_put(db->phy_node);
> sunxi_sram_release(&pdev->dev);
> - clk_disable_unprepare(db->clk);
> irq_dispose_mapping(ndev->irq);
> iounmap(db->membase);
> free_netdev(ndev);
[Severity: Critical]
This problem wasn't introduced by this patch, but can releasing
db->rx_chan before unregister_netdev() in emac_remove() cause a
use-after-free [1]?
drivers/net/ethernet/allwinner/sun4i-emac.c:emac_remove() {
...
if (db->rx_chan) {
dmaengine_terminate_all(db->rx_chan);
dma_release_channel(db->rx_chan);
}
unregister_netdev(ndev);
...
}
Until unregister_netdev() shuts down the interface, an incoming packet can
still trigger an RX interrupt and submit DMA on the freed db->rx_chan:
CPU0 CPU1
emac_remove()
dma_release_channel(db->rx_chan)
emac_interrupt()
emac_rx()
emac_dma_inblk_32bit()
dmaengine_prep_slave_single(db->rx_chan, ...)
<-- use-after-free
unregister_netdev(ndev)
[1] https://sashiko.dev/#/bug/linux-bb13c48b-2561-4c90-be1e-ab97f0255c59
--
Sashiko AI review · https://sashiko.dev/#/patchset/780975ed-825f-4f9b-8ac2-67664a7a2a2f@web.de?part=1
prev parent reply other threads:[~2026-11-25 17:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 17:19 [PATCH] net: allwinner: Use devm_clk_get_enabled() in emac_probe() Markus Elfring
2026-11-24 20:17 ` Andy Shevchenko
2026-11-25 12:48 ` Markus Elfring
2026-11-25 17:22 ` sashiko-bot [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=sashiko-outbox-233833@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Markus.Elfring@web.de \
--cc=linux-sunxi@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.