Skip to contentSkip to conversation

w1_remove_master_device(): fix check-after-use

PATCH In review Adrian Bunk 2 participants 2 messages Aug 14, 2007 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w1_remove_master_device(): fix check-after-use

The Coverity checker spotted that we'd have already oops'ed if "dev" was NULL.

---

drivers/w1/w1_int.c renamed from drivers/w1/w1_int.c.old +0 -5
@@ -171,22 +171,17 @@
 void w1_remove_master_device(struct w1_bus_master *bm)
 {
 	struct w1_master *dev = NULL;
 
 	list_for_each_entry(dev, &w1_masters, w1_master_entry) {
 		if (!dev->initialized)
 			continue;
 
 		if (dev->bus_master->data == bm->data)
 			break;
 	}
 
-	if (!dev) {
-		printk(KERN_ERR "Device doesn't exist.\n");
-		return;
-	}
-
 	__w1_remove_master_device(dev);
 }
 
 EXPORT_SYMBOL(w1_add_master_device);
 EXPORT_SYMBOL(w1_remove_master_device);
#1 lore raw

Hi Adrian.

Quoted 2 lines · Adrian Bunk

The Coverity checker spotted that we'd have already oops'ed if "dev" was NULL.

This is wrong.
Although dev can not be null there there is no way it will crash. The right paranoidal solution is to setup new pointer and make it equal to the found device and check if it is NULL or not out of the loop. I will cook up a patch tomorrow, thanks for pointing to this issue.

Signature · 1 line
	Evgeniy Polyakov