aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorGoldwyn Rodrigues <rgoldwyn@suse.de>2011-07-04 12:26:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-04 18:53:28 -0400
commitb2bc4782191cb574924a1d09f48083ea8b33a93b (patch)
treee91ef7b6fb2869908ce1aa7372747687ad0b5ec3 /drivers/infiniband
parentba466c74d99b91b2f390a09ad31bbc6cddd8cf4b (diff)
RDMA: Check for NULL mode in .devnode methods
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>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/cm.c3
-rw-r--r--drivers/infiniband/core/uverbs_main.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index f62f52fb9ece..fc0f2bd9ca82 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3641,7 +3641,8 @@ static struct kobj_type cm_port_obj_type = {
3641 3641
3642static char *cm_devnode(struct device *dev, mode_t *mode) 3642static char *cm_devnode(struct device *dev, mode_t *mode)
3643{ 3643{
3644 *mode = 0666; 3644 if (mode)
3645 *mode = 0666;
3645 return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev)); 3646 return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
3646} 3647}
3647 3648
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index e49a85f8a44d..56898b6578a4 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -826,7 +826,8 @@ static void ib_uverbs_remove_one(struct ib_device *device)
826 826
827static char *uverbs_devnode(struct device *dev, mode_t *mode) 827static char *uverbs_devnode(struct device *dev, mode_t *mode)
828{ 828{
829 *mode = 0666; 829 if (mode)
830 *mode = 0666;
830 return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev)); 831 return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
831} 832}
832 833