Skip to content

Commit f65d1f0

Browse files
error27davem330
authored andcommitted
hamradio: avoid null deref v3
This should address the problems in version 1 (lazy) and version 2 (ugly). Bump the stats on orig_dev not on the newly assigned NULL dev variable. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c064efc commit f65d1f0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/net/hamradio/bpqether.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ static netdev_tx_t bpq_xmit(struct sk_buff *skb, struct net_device *dev)
248248
{
249249
unsigned char *ptr;
250250
struct bpqdev *bpq;
251+
struct net_device *orig_dev;
251252
int size;
252253

253254
/*
@@ -282,8 +283,9 @@ static netdev_tx_t bpq_xmit(struct sk_buff *skb, struct net_device *dev)
282283

283284
bpq = netdev_priv(dev);
284285

286+
orig_dev = dev;
285287
if ((dev = bpq_get_ether_dev(dev)) == NULL) {
286-
dev->stats.tx_dropped++;
288+
orig_dev->stats.tx_dropped++;
287289
kfree_skb(skb);
288290
return NETDEV_TX_OK;
289291
}

0 commit comments

Comments
 (0)