net: xilinx: axienet: Add error handling for RX metadata pointer retrieval
Subsystems (5)
PATCH v2 1/1 net: xilinx: axienet: Add error handling for RX metadata pointer retrieval
Add proper error checking for dmaengine_desc_get_metadata_ptr() which can return an error pointer and lead to potential crashes or undefined behaviour if the pointer retrieval fails.
Properly handle the error by unmapping DMA buffer, freeing the skb and returning early to prevent further processing with invalid data.
---
Changes in v2:
Update the alias to net
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +11 -0
@@ -1166,8 +1166,18 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result) skb = skbuf_dma->skb; app_metadata =dmaengine_desc_get_metadata_ptr (skbuf_dma->desc, &meta_len, &meta_max_len); +dma_unmap_single (lp->dev, skbuf_dma->dma_address, lp->max_frm_size,DMA_FROM_DEVICE ); + +if (IS_ERR (app_metadata)) { +if (net_ratelimit ()) +netdev_err (lp->ndev,"Failed to get RX metadata pointer\n" ); +dev_kfree_skb_any (skb); + lp->ndev->stats.rx_dropped++; + goto rx_submit; + } +/* TODO: Derive app word index programmatically */ rx_len = (app_metadata[LEN_APP ] &0xFFFF );skb_put (skb, rx_len);
@@ -1180,6 +1190,7 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)u64_stats_add (&lp->rx_bytes, rx_len);u64_stats_update_end (&lp->rx_stat_sync); +rx_submit:for (i =0 ; i <CIRC_SPACE (lp->rx_ring_head, lp->rx_ring_tail,RX_BUF_NUM_DEFAULT ); i++)axienet_rx_submit_desc (lp->ndev);
Signature · 1 line
2.34.1
kernel test robot
build botFYI: kernel test robot notices the stable kernel rule is not satisfied.
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH net v2] net: xilinx: axienet: Add error handling for RX metadata pointer retrieval
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 16 lines
-----Original Message-----
From: Abin Joseph <[email protected]>
Sent: Tuesday, September 2, 2025 7:02 AM
To: Pandey, Radhey Shyam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Simek, Michal <[email protected]>
Cc: git (AMD-Xilinx) <[email protected]>; Joseph, Abin <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH net v2] net: xilinx: axienet: Add error handling for RX metadata pointer retrievalAdd proper error checking for
dmaengine_desc_get_metadata_ptr()which can return an error pointer and lead to potential crashes or undefined behaviour if the pointer retrieval fails.
Quoted 5 lines
Properly handle the error by unmapping DMA buffer, freeing the skb and returning early to prevent further processing with invalid data.
Fixes 6a91b846af85 ("net: axienet: Introduce dmaengine support")Signed-off-by Abin Joseph <[email protected]>
With one minor comment below-
Quoted 15 lines
---
Changes in v2:
Update the alias to net--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_rx_cb(void *data, const struct · line 1171
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0@@ -1166,8 +1166,18 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result) skb = skbuf_dma->skb; app_metadata =dmaengine_desc_get_metadata_ptr (skbuf_dma->desc, &meta_len, &meta_max_len); +
This is unrelated change.
Quoted 25 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0dma_unmap_single (lp->dev, skbuf_dma->dma_address, lp->max_frm_size,DMA_FROM_DEVICE ); + +if (IS_ERR (app_metadata)) { +if (net_ratelimit ()) +netdev_err (lp->ndev,"Failed to get RX metadata pointer\n" ); +dev_kfree_skb_any (skb); + lp->ndev->stats.rx_dropped++; + goto rx_submit; + } +/* TODO: Derive app word index programmatically */ rx_len = (app_metadata[LEN_APP] & 0xFFFF); skb_put(skb, rx_len);drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0@@ -1180,6 +1190,7 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result) u64_stats_add(&lp->rx_bytes, rx_len);u64_stats_update_end (&lp->rx_stat_sync); +rx_submit:for (i =0 ; i <CIRC_SPACE (lp->rx_ring_head, lp->rx_ring_tail,RX_BUF_NUM_DEFAULT ); i++)axienet_rx_submit_desc(lp->ndev);--
2.34.1