public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] w1_remove_master_device(): fix check-after-use
@ 2007-08-14 21:22 Adrian Bunk
  2007-08-14 22:22 ` Evgeniy Polyakov
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2007-08-14 21:22 UTC (permalink / raw)
  To: johnpol; +Cc: linux-kernel

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

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---
--- linux-2.6.23-rc1-mm2/drivers/w1/w1_int.c.old	2007-08-08 14:38:50.000000000 +0200
+++ linux-2.6.23-rc1-mm2/drivers/w1/w1_int.c	2007-08-08 14:38:58.000000000 +0200
@@ -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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [2.6 patch] w1_remove_master_device(): fix check-after-use
  2007-08-14 21:22 [2.6 patch] w1_remove_master_device(): fix check-after-use Adrian Bunk
@ 2007-08-14 22:22 ` Evgeniy Polyakov
  0 siblings, 0 replies; 2+ messages in thread
From: Evgeniy Polyakov @ 2007-08-14 22:22 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel

Hi Adrian.

On Tue, Aug 14, 2007 at 11:22:48PM +0200, Adrian Bunk (bunk@kernel.org) wrote:
> 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.

-- 
	Evgeniy Polyakov

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-14 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-14 21:22 [2.6 patch] w1_remove_master_device(): fix check-after-use Adrian Bunk
2007-08-14 22:22 ` Evgeniy Polyakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox