Thread (18 messages) 18 messages, 5 authors, 2023-11-08

Re: [PATCH net-next v8 5/7] net: phy: nxp-c45-tja11xx: add MACsec support

flat view

From: Radu Pirea (OSS) <hidden>
Date: 2023-11-08 10:49:05
Also in: lkml

On 04.11.2023 13:35, Simon Horman wrote:
On Mon, Oct 23, 2023 at 12:43:25PM +0300, Radu Pirea (NXP OSS) wrote:
quoted
+void nxp_c45_handle_macsec_interrupt(struct phy_device *phydev,
+				     irqreturn_t *ret)
+{
+	struct nxp_c45_phy *priv = phydev->priv;
+	struct nxp_c45_secy *pos, *tmp;
+	struct nxp_c45_sa *sa;
+	u8 encoding_sa;
+	int secy_id;
+	u32 reg = 0;
+
+	if (!priv->macsec)
+		return;
+
+	do {
+		nxp_c45_macsec_read(phydev, MACSEC_EVR, &reg);
+		if (!reg)
+			return;
+
+		secy_id = MACSEC_REG_SIZE - ffs(reg);
+		list_for_each_entry_safe(pos, tmp, &priv->macsec->secy_list,
+					 list)
+			if (pos->secy_id == secy_id)
+				break;
+
+		encoding_sa = pos->secy->tx_sc.encoding_sa;
Hi Radu,

I'm unsure if this can happen, but my understanding is that if
priv->macsec->secy_list is empty then pos will be uninitialised here.

Flagged by Coccinelle.
True, this this should never happen. No MACsec interrupt should be triggered if that list is empty. The IRQ for PN wrap is enabled only when a secy is added and disabled when the secy is removed. I added a safety check anyway.

-- 
Radu P.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help