summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Jón <tolvupostur@gmail.com>2016-08-12 13:50:41 +0200
committerSasha Levin <alexander.levin@verizon.com>2017-03-06 17:29:26 -0500
commit656e7d397516d7a961118367fe7f97004d2a2269 (patch)
treebe3418cc7cbc0ca91654df8c57c237f333b05630
parentde99814cbee7f39ced9900d377b6f11fa549fee6 (diff)
can: c_can_pci: fix null-pointer-deref in c_can_start() - set device pointer
[ Upstream commit c97c52be78b8463ac5407f1cf1f22f8f6cf93a37 ] The priv->device pointer for c_can_pci is never set, but it is used without a NULL check in c_can_start(). Setting it in c_can_pci_probe() like c_can_plat_probe() prevents c_can_pci.ko from crashing, with and without CONFIG_PM. This might also cause the pm_runtime_*() functions in c_can.c to actually be executed for c_can_pci devices - they are the only other place where priv->device is used, but they all contain a null check. Signed-off-by: Einar Jón <tolvupostur@gmail.com> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
-rw-r--r--drivers/net/can/c_can/c_can_pci.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c
index 7be393c96b1a..cf7c18947189 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -161,6 +161,7 @@ static int c_can_pci_probe(struct pci_dev *pdev,
dev->irq = pdev->irq;
priv->base = addr;
+ priv->device = &pdev->dev;
if (!c_can_pci_data->freq) {
dev_err(&pdev->dev, "no clock frequency defined\n");