From: sashiko-bot@kernel.org
To: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
wsa+renesas@sang-engineering.com
Subject: Re: [PATCH net-next v4 06/10] net: ethernet: ravb: Replace gPTP flags with callbacks
Date: Thu, 10 Sep 2026 17:31:44 +0000 [thread overview]
Message-ID: <20260910173144.844121F0089A@smtp.kernel.org> (raw)
In-Reply-To: <20260909173027.2201560-7-niklas.soderlund+renesas@ragnatech.se>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Critical] The PTP clock driver is leaked on the ravb_open() error path for Gen3 hardware, leading to a resource leak and Use-After-Free on unbind.
Pre-existing issues:
- [High] DMA descriptor rings and RX buffers are leaked if ravb_dmac_init() or ravb_open() fails.
--
commit e94a5eaa93f99ec3240945371b306afb7c9c715b
Author: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
net: ethernet: ravb: Replace gPTP flags with callbacks
This commit prepares for Gen4 support by replacing the Gen2 (info->gptp)
and Gen3 (info->ccc_gac) flags with callbacks in a new ravb_gptp_info
struct, simplifying hardware-specific checks.
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -712,8 +712,8 @@ static int ravb_dmac_init(struct net_device *ndev)
> return error;
>
> /* Initialise PTP Clock driver */
> - if (info->gptp)
> - ravb_ptp_init(ndev);
> + if (info->ptp && info->ptp->dmac_start)
> + return info->ptp->dmac_start(ndev);
[Severity: High]
This is a pre-existing issue, but does this error return leak the previously
allocated DMA descriptor rings and RX buffers?
If ravb_dmac_init() fails here (or at ravb_set_opmode earlier), the caller
ravb_open() branches to out_set_reset, which skips calling ravb_ring_free().
Because ravb_open() is reachable via a userspace command like ip link set up,
could this be triggered repeatedly to exhaust DMA coherent memory?
[ ... ]
> @@ -1124,8 +1124,8 @@ static int ravb_stop_dma(struct net_device *ndev)
> }
>
> /* Stop PTP Clock driver */
> - if (info->gptp)
> - ravb_ptp_stop(ndev);
> + if (info->ptp && info->ptp->dmac_stop)
> + info->ptp->dmac_stop(ndev);
[Severity: Critical]
For Gen3 devices, dmac_stop is NULL since they use ndev_close. If ravb_open()
fails during PHY initialization after the PTP clock has been started,
ravb_open() jumps to out_ptp_stop and calls ravb_stop_dma().
Since dmac_stop is NULL, does the PTP clock remain fully registered?
If the interface is left down and the module is subsequently removed,
unregister_netdev() will skip ravb_close(), leaving the PTP clock device
active. Could userspace then access the leaked /dev/ptpX device and trigger a
use-after-free on the freed priv pointer?
[ ... ]
> @@ -1967,8 +1957,11 @@ static int ravb_open(struct net_device *ndev)
> ravb_emac_init(ndev);
>
> /* Initialise PTP Clock driver */
> - if (info->ccc_gac)
> - ravb_ptp_init(ndev);
> + if (info->ptp && info->ptp->ndev_open) {
> + error = info->ptp->ndev_open(ndev);
> + if (error)
> + goto out_ptp_stop;
> + }
>
> /* PHY control start */
> error = ravb_phy_start(ndev);
[Severity: Critical]
If ravb_phy_start() fails, the code branches to out_ptp_stop, which calls
ravb_stop_dma(ndev). As noted above, ravb_stop_dma() will not clean up the
Gen3 PTP clock because dmac_stop is NULL.
Should the out_ptp_stop block in ravb_open() explicitly call
info->ptp->ndev_close(ndev) to ensure the clock is properly unregistered on
this error path?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909173027.2201560-1-niklas.soderlund+renesas@ragnatech.se?part=6
next prev parent reply other threads:[~2026-09-10 17:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 17:30 [PATCH net-next v4 00/10] ravb: Add gPTP support for Gen4 Niklas Söderlund
2026-09-09 17:30 ` [PATCH net-next v4 01/10] net: ethernet: ravb: Remove gPTP control from WoL setup and restore Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot
2026-09-09 17:30 ` [PATCH net-next v4 02/10] net: ethernet: ravb: Move programming of gPTP timer interval Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot
2026-09-09 17:30 ` [PATCH net-next v4 03/10] net: ethernet: ravb: Simplify gPTP start and stop Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot
2026-09-09 17:30 ` [PATCH net-next v4 04/10] net: ethernet: ravb: Remove redundant argument to ravb_ptp_init() Niklas Söderlund
2026-09-09 17:30 ` [PATCH net-next v4 05/10] net: ethernet: ravb: Propagate error from ptp_clock_register() Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot
2026-09-09 17:30 ` [PATCH net-next v4 06/10] net: ethernet: ravb: Replace gPTP flags with callbacks Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot [this message]
2026-09-09 17:30 ` [PATCH net-next v4 07/10] net: ethernet: ravb: Add callback for gPTP probe Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot
2026-09-09 17:30 ` [PATCH net-next v4 08/10] net: ethernet: ravb: Add callback for gPTP clock index Niklas Söderlund
2026-09-09 17:30 ` [PATCH net-next v4 09/10] dt-bindings: net: renesas,etheravb: Add optional gPTP phandle for Gen4 Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot
2026-09-09 17:30 ` [PATCH net-next v4 10/10] net: ethernet: ravb: Add gPTP support " Niklas Söderlund
2026-09-10 17:31 ` sashiko-bot
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=20260910173144.844121F0089A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=niklas.soderlund+renesas@ragnatech.se \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.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 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.