]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: ethernet: mtk_eth_soc: fix possible NULL pointer dereference in mtk_xdp_run
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 16 Aug 2022 14:16:15 +0000 (16:16 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 Aug 2022 04:59:14 +0000 (21:59 -0700)
Fix possible NULL pointer dereference in mtk_xdp_run() if the
ebpf program returns XDP_TX and xdp_convert_buff_to_frame routine fails
returning NULL.

Fixes: 1cb395c47bc4a ("net: ethernet: mtk_eth_soc: add xmit XDP support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/627a07d759020356b64473e09f0855960e02db28.1660659112.git.lorenzo@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mediatek/mtk_eth_soc.c

index d9426b01f462844dfac8d0e9b05d663ff25cf4c1..8aff4c0c28bd7c8d7f80390dd83b97b77d4896fb 100644 (file)
@@ -1732,7 +1732,7 @@ static u32 mtk_xdp_run(struct mtk_eth *eth, struct mtk_rx_ring *ring,
        case XDP_TX: {
                struct xdp_frame *xdpf = xdp_convert_buff_to_frame(xdp);
 
-               if (mtk_xdp_submit_frame(eth, xdpf, dev, false)) {
+               if (!xdpf || mtk_xdp_submit_frame(eth, xdpf, dev, false)) {
                        count = &hw_stats->xdp_stats.rx_xdp_tx_errors;
                        act = XDP_DROP;
                        break;