Commit 2dcc9347 authored by Wei Fang's avatar Wei Fang Committed by Paolo Abeni
Browse files

net: fec: remove unnecessary NULL pointer check when clearing TX BD ring



The tx_buf pointer will not NULL when its type is FEC_TXBUF_T_XDP_NDO or
FEC_TXBUF_T_XDP_TX. If the type is FEC_TXBUF_T_SKB, dev_kfree_skb_any()
will do NULL pointer check. So it is unnecessary to do NULL pointer check
in fec_enet_bd_init() and fec_enet_tx_queue().

Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
Reviewed-by: default avatarFrank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260205085742.2685134-10-wei.fang@nxp.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 2ff7a7d3
Loading
Loading
Loading
Loading
+12 −23
Original line number Diff line number Diff line
@@ -1032,24 +1032,19 @@ static void fec_enet_bd_init(struct net_device *dev)
							 fec32_to_cpu(bdp->cbd_bufaddr),
							 fec16_to_cpu(bdp->cbd_datlen),
							 DMA_TO_DEVICE);
				if (txq->tx_buf[i].buf_p)
				dev_kfree_skb_any(txq->tx_buf[i].buf_p);
			} else if (txq->tx_buf[i].type == FEC_TXBUF_T_XDP_NDO) {
				if (bdp->cbd_bufaddr)
				dma_unmap_single(&fep->pdev->dev,
						 fec32_to_cpu(bdp->cbd_bufaddr),
						 fec16_to_cpu(bdp->cbd_datlen),
						 DMA_TO_DEVICE);

				if (txq->tx_buf[i].buf_p)
				xdp_return_frame(txq->tx_buf[i].buf_p);
			} else {
				struct page *page = txq->tx_buf[i].buf_p;

				if (page)
				page_pool_put_page(pp_page_to_nmdesc(page)->pp,
							   page, 0,
							   false);
						   page, 0, false);
			}

			txq->tx_buf[i].buf_p = NULL;
@@ -1538,7 +1533,6 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)

			if (txq->tx_buf[index].type == FEC_TXBUF_T_XDP_NDO) {
				xdpf = txq->tx_buf[index].buf_p;
				if (bdp->cbd_bufaddr)
				dma_unmap_single(&fep->pdev->dev,
						 fec32_to_cpu(bdp->cbd_bufaddr),
						 fec16_to_cpu(bdp->cbd_datlen),
@@ -1548,11 +1542,6 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
			}

			bdp->cbd_bufaddr = cpu_to_fec32(0);
			if (unlikely(!txq->tx_buf[index].buf_p)) {
				txq->tx_buf[index].type = FEC_TXBUF_T_SKB;
				goto tx_buf_done;
			}

			frame_len = fec16_to_cpu(bdp->cbd_datlen);
		}