]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/staging-pi433-fix-potential-null-dereference.patch
autosel patches for 4.19
[thirdparty/kernel/stable-queue.git] / queue-4.19 / staging-pi433-fix-potential-null-dereference.patch
1 From 9d81578227955ae6c58b1cf6eef2bf76eee4a757 Mon Sep 17 00:00:00 2001
2 From: Michael Straube <straube.linux@gmail.com>
3 Date: Sun, 25 Nov 2018 10:22:25 +0100
4 Subject: staging: pi433: fix potential null dereference
5
6 [ Upstream commit 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 ]
7
8 Add a test for successful call to cdev_alloc() to avoid
9 potential null dereference. Issue reported by smatch.
10
11 Signed-off-by: Michael Straube <straube.linux@gmail.com>
12 Fixes: 874bcba65f9a ("staging: pi433: New driver")
13 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 Signed-off-by: Sasha Levin <sashal@kernel.org>
15 ---
16 drivers/staging/pi433/pi433_if.c | 4 ++++
17 1 file changed, 4 insertions(+)
18
19 diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
20 index c85a805a1243..a497ec197872 100644
21 --- a/drivers/staging/pi433/pi433_if.c
22 +++ b/drivers/staging/pi433/pi433_if.c
23 @@ -1255,6 +1255,10 @@ static int pi433_probe(struct spi_device *spi)
24
25 /* create cdev */
26 device->cdev = cdev_alloc();
27 + if (!device->cdev) {
28 + dev_dbg(device->dev, "allocation of cdev failed");
29 + goto cdev_failed;
30 + }
31 device->cdev->owner = THIS_MODULE;
32 cdev_init(device->cdev, &pi433_fops);
33 retval = cdev_add(device->cdev, device->devt, 1);
34 --
35 2.19.1
36