Skip to contentSkip to conversation

wimax: wimax_msg_alloc() returns ERR_PTR not null

PATCH In review Dan Carpenter 3 participants 3 messages Apr 22, 2010

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

PATCH 1/1 wimax: wimax_msg_alloc() returns ERR_PTR not null

wimax_msg_alloc() returns an ERR_PTR and not null. I changed it to test for ERR_PTR instead of null. I also added a check in front of the kfree() because kfree() can handle null but not ERR_PTR.

drivers/net/wimax/i2400m/rx.c +4 -5
index fa2e11e..05e2247 100644
@@ -300,17 +300,16 @@ void i2400m_rx_ctl_ack(struct i2400m *i2400m,
 		d_printf(1, dev, "Huh? waiter for command reply cancelled\n");
 		goto error_waiter_cancelled;
 	}
-	if (ack_skb = NULL) {
+	if (IS_ERR(ack_skb))
 		dev_err(dev, "CMD/GET/SET ack: cannot allocate SKB\n");
-		i2400m->ack_skb = ERR_PTR(-ENOMEM);
-	} else
-		i2400m->ack_skb = ack_skb;
+	i2400m->ack_skb = ack_skb;
 	spin_unlock_irqrestore(&i2400m->rx_lock, flags);
 	complete(&i2400m->msg_completion);
 	return;
 
 error_waiter_cancelled:
-	kfree_skb(ack_skb);
+	if (!IS_ERR(ack_skb))
+		kfree_skb(ack_skb);
 error_no_waiter:
 	spin_unlock_irqrestore(&i2400m->rx_lock, flags);
 	return;
#1 lore raw
Quoted 5 lines · Dan Carpenter

wimax_msg_alloc() returns an ERR_PTR and not null. I changed it to test for ERR_PTR instead of null. I also added a check in front of the kfree() because kfree() can handle null but not ERR_PTR.

Good catch thank you!

Will merge ASAP in preparation for the next push

maintainer
#2 lore raw

From: Inaky Perez-Gonzalez <[email protected]>
Date: Thu, 22 Apr 2010 14:59:56 -0700

Quoted 10 lines · Dan Carpenter
Quoted 5 lines

wimax_msg_alloc() returns an ERR_PTR and not null. I changed it to test for ERR_PTR instead of null. I also added a check in front of the kfree() because kfree() can handle null but not ERR_PTR.

Good catch thank you!

Will merge ASAP in preparation for the next push

There was another wimax fix from Dan, subject:

[patch] wimax: checking ERR_PTR vs null

make sure you integrate that one too.