]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.46/can-c_can_pci-fix-null-pointer-deref-in-c_can_start-set-device-pointer.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.46 / can-c_can_pci-fix-null-pointer-deref-in-c_can_start-set-device-pointer.patch
1 From c97c52be78b8463ac5407f1cf1f22f8f6cf93a37 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Einar=20J=C3=B3n?= <tolvupostur@gmail.com>
3 Date: Fri, 12 Aug 2016 13:50:41 +0200
4 Subject: can: c_can_pci: fix null-pointer-deref in c_can_start() - set device pointer
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Einar Jón <tolvupostur@gmail.com>
10
11 commit c97c52be78b8463ac5407f1cf1f22f8f6cf93a37 upstream.
12
13 The priv->device pointer for c_can_pci is never set, but it is used
14 without a NULL check in c_can_start(). Setting it in c_can_pci_probe()
15 like c_can_plat_probe() prevents c_can_pci.ko from crashing, with and
16 without CONFIG_PM.
17
18 This might also cause the pm_runtime_*() functions in c_can.c to
19 actually be executed for c_can_pci devices - they are the only other
20 place where priv->device is used, but they all contain a null check.
21
22 Signed-off-by: Einar Jón <tolvupostur@gmail.com>
23 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 drivers/net/can/c_can/c_can_pci.c | 1 +
28 1 file changed, 1 insertion(+)
29
30 --- a/drivers/net/can/c_can/c_can_pci.c
31 +++ b/drivers/net/can/c_can/c_can_pci.c
32 @@ -161,6 +161,7 @@ static int c_can_pci_probe(struct pci_de
33
34 dev->irq = pdev->irq;
35 priv->base = addr;
36 + priv->device = &pdev->dev;
37
38 if (!c_can_pci_data->freq) {
39 dev_err(&pdev->dev, "no clock frequency defined\n");