提交 59d9445e 编写于 作者: E Evgeniy Polyakov 提交者: Linus Torvalds

w1: fix w1_remove_master_device() searching

In case bus master driver provided bogus value as its private data, search
can be incorrect.  Problem found by Adrian Bunk.
Signed-off-by: NEvgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: Adrian Bunk <bunk@stusta.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 a89182c7
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册