]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.154/can-mpc5xxx_can-check-of_iomap-return-before-use.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.154 / can-mpc5xxx_can-check-of_iomap-return-before-use.patch
CommitLineData
ef332cb8
GKH
1From foo@baz Tue Aug 28 16:10:37 CEST 2018
2From: Nicholas Mc Guire <hofrat@osadl.org>
3Date: Mon, 9 Jul 2018 21:16:40 +0200
4Subject: can: mpc5xxx_can: check of_iomap return before use
5
6From: Nicholas Mc Guire <hofrat@osadl.org>
7
8[ Upstream commit b5c1a23b17e563b656cc9bb76ce5323b997d90e8 ]
9
10of_iomap() can return NULL so that return needs to be checked and NULL
11treated as failure. While at it also take care of the missing
12of_node_put() in the error path.
13
14Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
15Fixes: commit afa17a500a36 ("net/can: add driver for mscan family & mpc52xx_mscan")
16Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
17Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
18Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19---
20 drivers/net/can/mscan/mpc5xxx_can.c | 5 +++++
21 1 file changed, 5 insertions(+)
22
23--- a/drivers/net/can/mscan/mpc5xxx_can.c
24+++ b/drivers/net/can/mscan/mpc5xxx_can.c
25@@ -86,6 +86,11 @@ static u32 mpc52xx_can_get_clock(struct
26 return 0;
27 }
28 cdm = of_iomap(np_cdm, 0);
29+ if (!cdm) {
30+ of_node_put(np_cdm);
31+ dev_err(&ofdev->dev, "can't map clock node!\n");
32+ return 0;
33+ }
34
35 if (in_8(&cdm->ipb_clk_sel) & 0x1)
36 freq *= 2;