]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.69/mailbox-xgene-slimpro-fix-potential-null-pointer-dereference.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / mailbox-xgene-slimpro-fix-potential-null-pointer-dereference.patch
1 From 3512a18cbd8d09e22a790540cb9624c3c49827ba Mon Sep 17 00:00:00 2001
2 From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
3 Date: Thu, 26 Jul 2018 12:11:39 -0500
4 Subject: mailbox: xgene-slimpro: Fix potential NULL pointer dereference
5
6 From: Gustavo A. R. Silva <gustavo@embeddedor.com>
7
8 commit 3512a18cbd8d09e22a790540cb9624c3c49827ba upstream.
9
10 There is a potential execution path in which function
11 platform_get_resource() returns NULL. If this happens,
12 we will end up having a NULL pointer dereference.
13
14 Fix this by replacing devm_ioremap with devm_ioremap_resource,
15 which has the NULL check and the memory region request.
16
17 This code was detected with the help of Coccinelle.
18
19 Cc: stable@vger.kernel.org
20 Fixes: f700e84f417b ("mailbox: Add support for APM X-Gene platform mailbox driver")
21 Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
22 Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25 ---
26 drivers/mailbox/mailbox-xgene-slimpro.c | 6 +++---
27 1 file changed, 3 insertions(+), 3 deletions(-)
28
29 --- a/drivers/mailbox/mailbox-xgene-slimpro.c
30 +++ b/drivers/mailbox/mailbox-xgene-slimpro.c
31 @@ -195,9 +195,9 @@ static int slimpro_mbox_probe(struct pla
32 platform_set_drvdata(pdev, ctx);
33
34 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
35 - mb_base = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
36 - if (!mb_base)
37 - return -ENOMEM;
38 + mb_base = devm_ioremap_resource(&pdev->dev, regs);
39 + if (IS_ERR(mb_base))
40 + return PTR_ERR(mb_base);
41
42 /* Setup mailbox links */
43 for (i = 0; i < MBOX_CNT; i++) {