Commit 64c4c4ca authored by Michael Straube's avatar Michael Straube Committed by Greg Kroah-Hartman

staging: pi433: fix potential null dereference

Add a test for successful call to cdev_alloc() to avoid
potential null dereference. Issue reported by smatch.
Signed-off-by: default avatarMichael Straube <straube.linux@gmail.com>
Fixes: 874bcba6 ("staging: pi433: New driver")
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2a68ead3
......@@ -1245,6 +1245,10 @@ static int pi433_probe(struct spi_device *spi)
/* create cdev */
device->cdev = cdev_alloc();
if (!device->cdev) {
dev_dbg(device->dev, "allocation of cdev failed");
goto cdev_failed;
}
device->cdev->owner = THIS_MODULE;
cdev_init(device->cdev, &pi433_fops);
retval = cdev_add(device->cdev, device->devt, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment