From dbd2df859a4d992ccbceeb22c37f6a6c4aa4dc01 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 7 May 2013 08:27:16 -0300 Subject: [PATCH] serial: 8250_dw: Add valid clk pointer check Commit ffc3ae6dd "serial: 8250_dw: Enable runtime PM" introduced runtime PM management, which enables/disables the clk without checking if the clk is valid. However, this driver allows to be probed without a defined clk, using clock-frequency, as a fallback. Therefore, on platforms that are device tree probed using clock-frequency instead of clk, we get an ugly NULL pointer dereference. This patch fixes it by simply adding a check before accessing the clk api. Signed-off-by: Ezequiel Garcia Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_dw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index beaa283f5cc6..0b0eef900cad 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -338,7 +338,8 @@ static int dw8250_runtime_suspend(struct device *dev) { struct dw8250_data *data = dev_get_drvdata(dev); - clk_disable_unprepare(data->clk); + if (!IS_ERR(data->clk)) + clk_disable_unprepare(data->clk); return 0; } @@ -347,7 +348,8 @@ static int dw8250_runtime_resume(struct device *dev) { struct dw8250_data *data = dev_get_drvdata(dev); - clk_prepare_enable(data->clk); + if (!IS_ERR(data->clk)) + clk_prepare_enable(data->clk); return 0; } -- 2.20.1