summaryrefslogtreecommitdiffstats
path: root/net/core/netpoll.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2020-05-07 09:32:21 -0700
committerDavid S. Miller <davem@davemloft.net>2020-05-07 18:11:07 -0700
commitf78ed2204db9fc35b545d693865bddbe0149aa1f (patch)
tree547a43f4bee21b4880397429cca2a02ab85f397c /net/core/netpoll.c
parent1ddabdfaf70c202b88925edd74c66f4707dbd92e (diff)
downloadlinux-f78ed2204db9fc35b545d693865bddbe0149aa1f.tar.bz2
netpoll: accept NULL np argument in netpoll_send_skb()
netpoll_send_skb() callers seem to leak skb if the np pointer is NULL. While this should not happen, we can make the code more robust. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/netpoll.c')
-rw-r--r--net/core/netpoll.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 40d2753aa47d..093e90e52bc2 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -367,9 +367,14 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
unsigned long flags;
netdev_tx_t ret;
- local_irq_save(flags);
- ret = __netpoll_send_skb(np, skb);
- local_irq_restore(flags);
+ if (unlikely(!np)) {
+ dev_kfree_skb_irq(skb);
+ ret = NET_XMIT_DROP;
+ } else {
+ local_irq_save(flags);
+ ret = __netpoll_send_skb(np, skb);
+ local_irq_restore(flags);
+ }
return ret;
}
EXPORT_SYMBOL(netpoll_send_skb);