From: Parvathi Pudi <parvathi@couthit.com>
To: Simon Horman <horms@kernel.org>
Cc: parvathi <parvathi@couthit.com>,
andrew+netdev <andrew+netdev@lunn.ch>,
davem <davem@davemloft.net>, edumazet <edumazet@google.com>,
kuba <kuba@kernel.org>, pabeni <pabeni@redhat.com>,
danishanwar <danishanwar@ti.com>, rogerq <rogerq@kernel.org>,
pmohan <pmohan@couthit.com>, afd <afd@ti.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
haokexin <haokexin@gmail.com>, basharath <basharath@couthit.com>,
arnd <arnd@arndb.de>,
linux-kernel <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
pratheesh <pratheesh@ti.com>, j-rameshbabu <j-rameshbabu@ti.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
praneeth <praneeth@ti.com>, srk <srk@ti.com>,
rogerq <rogerq@ti.com>, m-malladi <m-malladi@ti.com>,
krishna <krishna@couthit.com>, mohan <mohan@couthit.com>
Subject: Re: [PATCH net-next v4 2/3] net: ti: icssm-prueth: Add priority based RX IRQ handlers
Date: Thu, 1 Oct 2026 18:38:27 +0530 (IST) [thread overview]
Message-ID: <1971584479.492761.1790860107401.JavaMail.zimbra@couthit.local> (raw)
In-Reply-To: <20260925163933.721156-1-horms@kernel.org>
Hi,
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> Full review at:
> https://sashiko.dev/#/patchset/20260921134343.200426-4-parvathi@couthit.com?part=2
> ---
> Subject: net: ti: icssm-prueth: Add priority based RX IRQ handlers
>
> This commit adds support for priority-based interrupt handling for the STP/RSTP
> Switch, HSR, and PRP protocols to address port dominance. It records an IEP
> hardware timestamp into the receive buffer to guarantee frames are delivered in
> wire-arrival order. The patch also converts statistics counters to atomic64_t
> and adds a firmware revision field to support different timestamp wraparound
> behaviors.
>
>> diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> index 6c8888d9d66a6..4a37935b8d352 100644
>> --- a/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
> [ ... ]
>> @@ -1071,11 +1083,25 @@ static int icssm_emac_ndo_open(struct net_device *ndev)
>> goto iep_exit;
>> }
>>
>> - ret = icssm_emac_request_irqs(emac);
>> - if (ret)
>> - goto rproc_shutdown;
>> + if (PRUETH_IS_EMAC(prueth)) {
>> + napi_enable(&emac->napi);
>> + } else {
>> + if (!prueth->emac_configured &&
>> + (PRUETH_IS_SWITCH(prueth) || prueth_is_lre(prueth))) {
>> + napi_enable(&prueth->napi_hpq);
>> + napi_enable(&prueth->napi_lpq);
>
> [Severity: High]
> Does this code risk a NULL pointer dereference?
>
> If MII0 is missing (e.g., absent from the device tree), the shared NAPI
> structures napi_hpq and napi_lpq are not initialized in
> icssm_prueth_netdev_init(). If the MII1 interface is later placed into SWITCH
> mode and brought up, it appears icssm_emac_ndo_open() will unconditionally call
> napi_enable() on these zero-initialized structures, causing a NULL pointer
> dereference on n->dev.
>
No, this condition will never occur. The shared NAPIs are used only in SWITCH/HSR/PRP
modes, and the driver switches to those modes only when both MII0 and MII1 are members
of the same bridge/HSR device. If MII0 is absent from the DT, its netdev is never
created, so it can never join a bridge/HSR device and the both-ports condition is never
met. The device therefore always stays in EMAC mode, and icssm_emac_ndo_open() enables
only the per-port emac->napi, which is always initialized.
>> + }
>> + }
> [ ... ]
>> @@ -1780,9 +1820,25 @@ static int icssm_prueth_netdev_init(struct prueth
>> *prueth,
>>
>> netif_napi_add(ndev, &emac->napi, icssm_emac_napi_poll);
>>
>> + if ((prueth->support_lre || fw_data->support_switch) &&
>> + emac->port_id == PRUETH_PORT_MII0) {
>> + netif_napi_add(ndev, &prueth->napi_hpq,
>> + icssm_prueth_common_napi_poll_hpq);
>> + netif_napi_add(ndev, &prueth->napi_lpq,
>> + icssm_prueth_common_napi_poll_lpq);
>> + }
>> +
>> hrtimer_setup(&emac->tx_hrtimer, &icssm_emac_tx_timer_callback,
>> CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
>>
>> + if ((prueth->support_lre || fw_data->support_switch) &&
>> + emac->port_id == PRUETH_PORT_MII0) {
>> + prueth->hp->ndev = ndev;
>> + prueth->hp->priority = 0;
>> + prueth->lp->ndev = ndev;
>> + prueth->lp->priority = 1;
>> + }
>> +
>> return 0;
> [ ... ]
>> diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth_common.c
>> b/drivers/net/ethernet/ti/icssm/icssm_prueth_common.c
>> new file mode 100644
>> index 0000000000000..9b7b876240b5f
>> --- /dev/null
>> +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth_common.c
> [ ... ]
>> +static irqreturn_t icssm_prueth_common_emac_rx_hardirq(int irq, void *dev_id)
>> +{
>> + struct prueth_ndev_priority *ndev_prio;
>> + struct prueth_emac *emac;
>> + struct net_device *ndev;
>> + struct prueth *prueth;
>> +
>> + ndev_prio = (struct prueth_ndev_priority *)dev_id;
>> + ndev = ndev_prio->ndev;
>
> [Severity: High]
> Similarly, can this IRQ handler dereference an uninitialized pointer?
>
> If MII0 is missing and these priority structures were skipped during
> initialization, it looks like the registered IRQ handler will dereference the
> zero-initialized ndev_prio->ndev here when an interrupt occurs.
>
Same as above. This handler is registered only by icssm_prueth_common_request_irqs(),
which is called only in SWITCH/HSR/PRP modes. In EMAC mode, each port uses its own
RX IRQ and handler through icssm_emac_request_irqs(). Since the device always
stays in EMAC mode when MII0 is absent, this handler is never registered and never
runs with a zeroed ndev_prio→ndev.
>> + emac = netdev_priv(ndev);
>> + prueth = emac->prueth;
>
> [Severity: Medium]
> This is a pre-existing issue, but can the transmission path read out of bounds?
>
> In drivers/net/ethernet/ti/icssm/icssm_prueth.c:icssm_prueth_get_tx_queue_id():
>
> err = vlan_get_tag(skb, &vlan_tci);
>
> icssm_emac_ndo_start_xmit() calls icssm_prueth_get_tx_queue_id() before
> validating the length of the transmitted skb or padding it. Because the device
> lacks NETIF_F_HW_VLAN_CTAG_TX, vlan_get_tag() falls back to __vlan_get_tag(),
> which reads the VLAN TCI at offset 14. If a raw socket transmits a packet
> smaller than 18 bytes (e.g., exactly 14 bytes) with h_vlan_proto ==
> ETH_P_8021Q, this reads unallocated memory past the buffer.
As this is a pre-existing issue related to the TX path VLAN tag check in
icssm_prueth_get_tx_queue_id(), we will address it separately in a different series.
Thanks and Regards,
Parvathi.
next prev parent reply other threads:[~2026-10-01 13:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 13:41 [PATCH net-next v4 0/3] Introduce HSR/PRP HW offload support for PRU-ICSSM Ethernet driver Parvathi Pudi
2026-09-21 13:41 ` [PATCH net-next v4 1/3] net: ti: icssm-prueth: Add HSR and PRP HW offload mode support for AM57xx, AM437x and AM335x Parvathi Pudi
2026-09-25 16:39 ` Simon Horman
2026-10-01 13:04 ` Parvathi Pudi
2026-09-21 13:41 ` [PATCH net-next v4 2/3] net: ti: icssm-prueth: Add priority based RX IRQ handlers Parvathi Pudi
2026-09-25 16:39 ` Simon Horman
2026-10-01 13:08 ` Parvathi Pudi [this message]
2026-09-21 13:41 ` [PATCH net-next v4 3/3] net: ti: icssm-prueth: Support duplicate HW offload feature for HSR and PRP Parvathi Pudi
2026-09-25 16:39 ` Simon Horman
2026-10-01 13:10 ` Parvathi Pudi
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=1971584479.492761.1790860107401.JavaMail.zimbra@couthit.local \
--to=parvathi@couthit.com \
--cc=afd@ti.com \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=basharath@couthit.com \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=haokexin@gmail.com \
--cc=horms@kernel.org \
--cc=j-rameshbabu@ti.com \
--cc=krishna@couthit.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-malladi@ti.com \
--cc=mohan@couthit.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmohan@couthit.com \
--cc=praneeth@ti.com \
--cc=pratheesh@ti.com \
--cc=rogerq@kernel.org \
--cc=rogerq@ti.com \
--cc=srk@ti.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vigneshr@ti.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®