OSDN Git Service

dpaa2-eth: check the result of skb_to_sgvec()
authorIoana Ciornei <ioana.ciornei@nxp.com>
Wed, 24 Jun 2020 11:34:18 +0000 (14:34 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 25 Jun 2020 23:03:39 +0000 (16:03 -0700)
Before passing the result of skb_to_sgvec() to dma_map_sg() check if any
error was returned.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

index f150cd4..db27f95 100644 (file)
@@ -611,6 +611,10 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
 
        sg_init_table(scl, nr_frags + 1);
        num_sg = skb_to_sgvec(skb, scl, 0, skb->len);
+       if (unlikely(num_sg < 0)) {
+               err = -ENOMEM;
+               goto dma_map_sg_failed;
+       }
        num_dma_bufs = dma_map_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL);
        if (unlikely(!num_dma_bufs)) {
                err = -ENOMEM;