Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: mpc5xxx_can: check of_iomap return before use

of_iomap() can return NULL so that return needs to be checked and NULL
treated as failure. While at it also take care of the missing
of_node_put() in the error path.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit afa17a500a36 ("net/can: add driver for mscan family & mpc52xx_mscan")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Nicholas Mc Guire and committed by
Marc Kleine-Budde
b5c1a23b 393753b2

+5
+5
drivers/net/can/mscan/mpc5xxx_can.c
··· 86 86 return 0; 87 87 } 88 88 cdm = of_iomap(np_cdm, 0); 89 + if (!cdm) { 90 + of_node_put(np_cdm); 91 + dev_err(&ofdev->dev, "can't map clock node!\n"); 92 + return 0; 93 + } 89 94 90 95 if (in_8(&cdm->ipb_clk_sel) & 0x1) 91 96 freq *= 2;