Skip to content

Commit 2def09e

Browse files
Fushuai Wangkuba-moo
authored andcommitted
dpaa2-eth: fix xdp_rxq_info leak
The driver registered xdp_rxq_info structures via xdp_rxq_info_reg() but failed to properly unregister them in error paths and during removal. Fixes: d678be1 ("dpaa2-eth: add XDP_REDIRECT support") Signed-off-by: Fushuai Wang <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Ioana Ciornei <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d72411d commit 2def09e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3939,6 +3939,7 @@ static int dpaa2_eth_setup_rx_flow(struct dpaa2_eth_priv *priv,
39393939
MEM_TYPE_PAGE_ORDER0, NULL);
39403940
if (err) {
39413941
dev_err(dev, "xdp_rxq_info_reg_mem_model failed\n");
3942+
xdp_rxq_info_unreg(&fq->channel->xdp_rxq);
39423943
return err;
39433944
}
39443945

@@ -4432,17 +4433,25 @@ static int dpaa2_eth_bind_dpni(struct dpaa2_eth_priv *priv)
44324433
return -EINVAL;
44334434
}
44344435
if (err)
4435-
return err;
4436+
goto out;
44364437
}
44374438

44384439
err = dpni_get_qdid(priv->mc_io, 0, priv->mc_token,
44394440
DPNI_QUEUE_TX, &priv->tx_qdid);
44404441
if (err) {
44414442
dev_err(dev, "dpni_get_qdid() failed\n");
4442-
return err;
4443+
goto out;
44434444
}
44444445

44454446
return 0;
4447+
4448+
out:
4449+
while (i--) {
4450+
if (priv->fq[i].type == DPAA2_RX_FQ &&
4451+
xdp_rxq_info_is_reg(&priv->fq[i].channel->xdp_rxq))
4452+
xdp_rxq_info_unreg(&priv->fq[i].channel->xdp_rxq);
4453+
}
4454+
return err;
44464455
}
44474456

44484457
/* Allocate rings for storing incoming frame descriptors */
@@ -4825,6 +4834,17 @@ static void dpaa2_eth_del_ch_napi(struct dpaa2_eth_priv *priv)
48254834
}
48264835
}
48274836

4837+
static void dpaa2_eth_free_rx_xdp_rxq(struct dpaa2_eth_priv *priv)
4838+
{
4839+
int i;
4840+
4841+
for (i = 0; i < priv->num_fqs; i++) {
4842+
if (priv->fq[i].type == DPAA2_RX_FQ &&
4843+
xdp_rxq_info_is_reg(&priv->fq[i].channel->xdp_rxq))
4844+
xdp_rxq_info_unreg(&priv->fq[i].channel->xdp_rxq);
4845+
}
4846+
}
4847+
48284848
static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
48294849
{
48304850
struct device *dev;
@@ -5028,6 +5048,7 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
50285048
free_percpu(priv->percpu_stats);
50295049
err_alloc_percpu_stats:
50305050
dpaa2_eth_del_ch_napi(priv);
5051+
dpaa2_eth_free_rx_xdp_rxq(priv);
50315052
err_bind:
50325053
dpaa2_eth_free_dpbps(priv);
50335054
err_dpbp_setup:
@@ -5080,6 +5101,7 @@ static void dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
50805101
free_percpu(priv->percpu_extras);
50815102

50825103
dpaa2_eth_del_ch_napi(priv);
5104+
dpaa2_eth_free_rx_xdp_rxq(priv);
50835105
dpaa2_eth_free_dpbps(priv);
50845106
dpaa2_eth_free_dpio(priv);
50855107
dpaa2_eth_free_dpni(priv);

0 commit comments

Comments
 (0)