Skip to content

Commit 92e2fc9

Browse files
abinJoseph25k07gregkh
authored andcommitted
net: xilinx: axienet: Add error handling for RX metadata pointer retrieval
[ Upstream commit 8bbceba ] 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. Fixes: 6a91b84 ("net: axienet: Introduce dmaengine support") Signed-off-by: Abin Joseph <abin.joseph@amd.com> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> Link: https://patch.msgid.link/20250903025213.3120181-1-abin.joseph@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 008db2e commit 92e2fc9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,15 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)
11681168
&meta_max_len);
11691169
dma_unmap_single(lp->dev, skbuf_dma->dma_address, lp->max_frm_size,
11701170
DMA_FROM_DEVICE);
1171+
1172+
if (IS_ERR(app_metadata)) {
1173+
if (net_ratelimit())
1174+
netdev_err(lp->ndev, "Failed to get RX metadata pointer\n");
1175+
dev_kfree_skb_any(skb);
1176+
lp->ndev->stats.rx_dropped++;
1177+
goto rx_submit;
1178+
}
1179+
11711180
/* TODO: Derive app word index programmatically */
11721181
rx_len = (app_metadata[LEN_APP] & 0xFFFF);
11731182
skb_put(skb, rx_len);
@@ -1180,6 +1189,7 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)
11801189
u64_stats_add(&lp->rx_bytes, rx_len);
11811190
u64_stats_update_end(&lp->rx_stat_sync);
11821191

1192+
rx_submit:
11831193
for (i = 0; i < CIRC_SPACE(lp->rx_ring_head, lp->rx_ring_tail,
11841194
RX_BUF_NUM_DEFAULT); i++)
11851195
axienet_rx_submit_desc(lp->ndev);

0 commit comments

Comments
 (0)