RDMA: Check for NULL mode in .devnode methods
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Mon, 4 Jul 2011 16:26:57 +0000 (09:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 4 Jul 2011 22:53:28 +0000 (15:53 -0700)
Commits 71c29bd5c235 ("IB/uverbs: Add devnode method to set path/mode")
and c3af0980ce01 ("IB: Add devnode methods to cm_class and umad_class")
added devnode methods that set the mode.

However, these methods don't check for a NULL mode, and so we get a
crash when unloading modules because devtmpfs_delete_node() calls
device_get_devnode() with mode == NULL.

Add the missing checks.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.de>
[ Also fix cm.c.  - Roland ]
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/infiniband/core/cm.c
drivers/infiniband/core/uverbs_main.c

index f62f52fb9ece776000fb98dc830d52bf8bfb4f57..fc0f2bd9ca82518b50653e794d68ac35237d40e7 100644 (file)
@@ -3641,7 +3641,8 @@ static struct kobj_type cm_port_obj_type = {
 
 static char *cm_devnode(struct device *dev, mode_t *mode)
 {
-       *mode = 0666;
+       if (mode)
+               *mode = 0666;
        return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
 }
 
index e49a85f8a44debe499e0bcd2c4d489174b5aab3d..56898b6578a49e4e4b3d006763b6f6a861a78d93 100644 (file)
@@ -826,7 +826,8 @@ static void ib_uverbs_remove_one(struct ib_device *device)
 
 static char *uverbs_devnode(struct device *dev, mode_t *mode)
 {
-       *mode = 0666;
+       if (mode)
+               *mode = 0666;
        return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
 }