Skip to content

Commit d0ecda6

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 <[email protected]> Reviewed-by: Radhey Shyam Pandey <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 4a5633b commit d0ecda6

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
@@ -1127,6 +1127,15 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)
11271127
&meta_max_len);
11281128
dma_unmap_single(lp->dev, skbuf_dma->dma_address, lp->max_frm_size,
11291129
DMA_FROM_DEVICE);
1130+
1131+
if (IS_ERR(app_metadata)) {
1132+
if (net_ratelimit())
1133+
netdev_err(lp->ndev, "Failed to get RX metadata pointer\n");
1134+
dev_kfree_skb_any(skb);
1135+
lp->ndev->stats.rx_dropped++;
1136+
goto rx_submit;
1137+
}
1138+
11301139
/* TODO: Derive app word index programmatically */
11311140
rx_len = (app_metadata[LEN_APP] & 0xFFFF);
11321141
skb_put(skb, rx_len);
@@ -1139,6 +1148,7 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)
11391148
u64_stats_add(&lp->rx_bytes, rx_len);
11401149
u64_stats_update_end(&lp->rx_stat_sync);
11411150

1151+
rx_submit:
11421152
for (i = 0; i < CIRC_SPACE(lp->rx_ring_head, lp->rx_ring_tail,
11431153
RX_BUF_NUM_DEFAULT); i++)
11441154
axienet_rx_submit_desc(lp->ndev);

0 commit comments

Comments
 (0)