driver-core: Fix possible null reference in subsys_interface_unregister
authorJonghwan Choi <jhbird.choi@samsung.com>
Sat, 14 Jan 2012 02:06:03 +0000 (11:06 +0900)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Jan 2012 23:59:19 +0000 (15:59 -0800)
Check if the sif is not NULL before de-referencing it

Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/bus.c

index 99dc5921e1dd28be8e6a910964dde8ca14900238..4ddb38b696fe5a23e047d38961463c595a3f4d6a 100644 (file)
@@ -1193,13 +1193,15 @@ EXPORT_SYMBOL_GPL(subsys_interface_register);
 
 void subsys_interface_unregister(struct subsys_interface *sif)
 {
-       struct bus_type *subsys = sif->subsys;
+       struct bus_type *subsys;
        struct subsys_dev_iter iter;
        struct device *dev;
 
-       if (!sif)
+       if (!sif || !sif->subsys)
                return;
 
+       subsys = sif->subsys;
+
        mutex_lock(&subsys->p->mutex);
        list_del_init(&sif->node);
        if (sif->remove_dev) {