mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
staging: pi433: fix potential null dereference
[ Upstream commit64c4c4ca6c] 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:874bcba65f("staging: pi433: New driver") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
23d18c183c
commit
84e4e56c9a
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user