summaryrefslogtreecommitdiff
path: root/drivers/staging/pi433
diff options
context:
space:
mode:
authorMichael Straube <straube.linux@gmail.com>2018-11-25 10:22:25 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-12 19:46:00 +0100
commit84e4e56c9a385b7a1fa1e683f6525391c2cd00f3 (patch)
tree5ea4a61a52e1626928668e3c6418af4c07b07f7f /drivers/staging/pi433
parent23d18c183c58e0c0ed49196f30dfaa4f6155d3b4 (diff)
staging: pi433: fix potential null dereference
[ Upstream commit 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 ] Add a test for successful call to cdev_alloc() to avoid potential null dereference. Issue reported by smatch. Signed-off-by: Michael Straube <straube.linux@gmail.com> Fixes: 874bcba65f9a ("staging: pi433: New driver") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/staging/pi433')
-rw-r--r--drivers/staging/pi433/pi433_if.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 93c01680f016..5be40bdc191b 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1210,6 +1210,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);