]>
Commit | Line | Data |
---|---|---|
ef332cb8 GKH |
1 | From foo@baz Tue Aug 28 16:10:37 CEST 2018 |
2 | From: Nicholas Mc Guire <hofrat@osadl.org> | |
3 | Date: Mon, 9 Jul 2018 21:16:40 +0200 | |
4 | Subject: can: mpc5xxx_can: check of_iomap return before use | |
5 | ||
6 | From: Nicholas Mc Guire <hofrat@osadl.org> | |
7 | ||
8 | [ Upstream commit b5c1a23b17e563b656cc9bb76ce5323b997d90e8 ] | |
9 | ||
10 | of_iomap() can return NULL so that return needs to be checked and NULL | |
11 | treated as failure. While at it also take care of the missing | |
12 | of_node_put() in the error path. | |
13 | ||
14 | Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> | |
15 | Fixes: commit afa17a500a36 ("net/can: add driver for mscan family & mpc52xx_mscan") | |
16 | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> | |
17 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
18 | Signed-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; |