Skip to content

Commit

Permalink
RDMA: Check for NULL mode in .devnode methods
Browse files Browse the repository at this point in the history
Commits 71c29bd ("IB/uverbs: Add devnode method to set path/mode")
and c3af098 ("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 <[email protected]>
[ Also fix cm.c.  - Roland ]
Signed-off-by: Roland Dreier <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Goldwyn Rodrigues authored and torvalds committed Jul 4, 2011
1 parent ba466c7 commit b2bc478
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/infiniband/core/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit b2bc478

Please sign in to comment.