Skip to content

Commit

Permalink
rapidio: fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
The change fixes improper check for a returned error value by
class_create() function, which on error returns ERR_PTR() value, thus the
original check always results in a dead code on error path.

Signed-off-by: Vladimir Zapolskiy <[email protected]>
Signed-off-by: Alexandre Bounine <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
vzapolskiy authored and torvalds committed Apr 29, 2016
1 parent c2e7e00 commit 99f23c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rapidio/devices/rio_mport_cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2669,9 +2669,9 @@ static int __init mport_init(void)

/* Create device class needed by udev */
dev_class = class_create(THIS_MODULE, DRV_NAME);
if (!dev_class) {
if (IS_ERR(dev_class)) {
rmcd_error("Unable to create " DRV_NAME " class");
return -EINVAL;
return PTR_ERR(dev_class);
}

ret = alloc_chrdev_region(&dev_number, 0, RIO_MAX_MPORTS, DRV_NAME);
Expand Down

0 comments on commit 99f23c2

Please sign in to comment.