]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.31/mfd-sm501-fix-potential-null-pointer-dereference.patch
Linux 4.19.31
[thirdparty/kernel/stable-queue.git] / releases / 4.19.31 / mfd-sm501-fix-potential-null-pointer-dereference.patch
1 From ae7b8eda27b33b1f688dfdebe4d46f690a8f9162 Mon Sep 17 00:00:00 2001
2 From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
3 Date: Tue, 22 Jan 2019 10:56:36 -0600
4 Subject: mfd: sm501: Fix potential NULL pointer dereference
5
6 From: Gustavo A. R. Silva <gustavo@embeddedor.com>
7
8 commit ae7b8eda27b33b1f688dfdebe4d46f690a8f9162 upstream.
9
10 There is a potential NULL pointer dereference in case devm_kzalloc()
11 fails and returns NULL.
12
13 Fix this by adding a NULL check on *lookup*
14
15 This bug was detected with the help of Coccinelle.
16
17 Fixes: b2e63555592f ("i2c: gpio: Convert to use descriptors")
18 Cc: stable@vger.kernel.org
19 Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
20 Signed-off-by: Lee Jones <lee.jones@linaro.org>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 drivers/mfd/sm501.c | 3 +++
25 1 file changed, 3 insertions(+)
26
27 --- a/drivers/mfd/sm501.c
28 +++ b/drivers/mfd/sm501.c
29 @@ -1145,6 +1145,9 @@ static int sm501_register_gpio_i2c_insta
30 lookup = devm_kzalloc(&pdev->dev,
31 sizeof(*lookup) + 3 * sizeof(struct gpiod_lookup),
32 GFP_KERNEL);
33 + if (!lookup)
34 + return -ENOMEM;
35 +
36 lookup->dev_id = "i2c-gpio";
37 if (iic->pin_sda < 32)
38 lookup->table[0].chip_label = "SM501-LOW";