Skip to content

Commit

Permalink
w1: fix w1_remove_master_device() searching
Browse files Browse the repository at this point in the history
In case bus master driver provided bogus value as its private data, search
can be incorrect.  Problem found by Adrian Bunk.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Evgeniy Polyakov authored and Linus Torvalds committed Aug 23, 2007
1 parent a89182c commit 59d9445
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/w1/w1_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,24 @@ void __w1_remove_master_device(struct w1_master *dev)

void w1_remove_master_device(struct w1_bus_master *bm)
{
struct w1_master *dev = NULL;
struct w1_master *dev, *found = NULL;

list_for_each_entry(dev, &w1_masters, w1_master_entry) {
if (!dev->initialized)
continue;

if (dev->bus_master->data == bm->data)
if (dev->bus_master->data == bm->data) {
found = dev;
break;
}
}

if (!dev) {
if (!found) {
printk(KERN_ERR "Device doesn't exist.\n");
return;
}

__w1_remove_master_device(dev);
__w1_remove_master_device(found);
}

EXPORT_SYMBOL(w1_add_master_device);
Expand Down

0 comments on commit 59d9445

Please sign in to comment.