Skip to contentSkip to conversation

hdlc: fix null-deref on allocation failure

PATCH Applied Stephen Hemminger 2 participants 2 messages Nov 17, 2015 – Nov 18, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hdlc: fix null-deref on allocation failure

If alloc_netdev() failed and return NULL, then the next instruction would dereference it. Found by Coverity.

Compile tested only. Not sure if anyone still uses this driver (or the whole WAN subsystem).

drivers/net/wan/hdlc_fr.c +5 -5
@@ -1075,11 +1075,10 @@ static int fr_add_pvc(struct net_device
 
 	used = pvc_is_used(pvc);
 
-	if (type == ARPHRD_ETHER) {
+	if (type == ARPHRD_ETHER)
 		dev = alloc_netdev(0, "pvceth%d", NET_NAME_UNKNOWN,
 				   ether_setup);
-		dev->priv_flags &= ~IFF_TX_SKB_SHARING;
-	} else
+	else
 		dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup);
 
 	if (!dev) {
@@ -1088,9 +1087,10 @@ static int fr_add_pvc(struct net_device
 		return -ENOBUFS;
 	}
 
-	if (type == ARPHRD_ETHER)
+	if (type == ARPHRD_ETHER) {
+		dev->priv_flags &= ~IFF_TX_SKB_SHARING;
 		eth_hw_addr_random(dev);
-	else {
+	} else {
 		*(__be16*)dev->dev_addr = htons(dlci);
 		dlci_to_q922(dev->broadcast, dlci);
 	}
maintainer Applied
#1 lore raw

From: Stephen Hemminger <[email protected]>
Date: Tue, 17 Nov 2015 14:26:06 -0800

Quoted 7 lines

If alloc_netdev() failed and return NULL, then the next instruction would dereference it. Found by Coverity.

Compile tested only. Not sure if anyone still uses this driver (or the whole WAN subsystem).

Applied.