vrf: fix NULL dereference in vrf_finish_output()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 6 Aug 2021 15:04:35 +0000 (18:04 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 6 Aug 2021 22:40:37 +0000 (15:40 -0700)
The "skb" pointer is NULL on this error path so we can't dereference it.
Use "dev" instead.

Fixes: 14ee70ca89e6 ("vrf: use skb_expand_head in vrf_finish_output")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20210806150435.GB15586@kili
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/vrf.c

index 726adf0..662e261 100644 (file)
@@ -864,7 +864,7 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s
        if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
                skb = skb_expand_head(skb, hh_len);
                if (!skb) {
-                       skb->dev->stats.tx_errors++;
+                       dev->stats.tx_errors++;
                        return -ENOMEM;
                }
        }