aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/8250
diff options
context:
space:
mode:
authorEzequiel Garcia <ezequiel.garcia@free-electrons.com>2013-05-07 07:27:16 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-20 14:54:55 -0400
commitdbd2df859a4d992ccbceeb22c37f6a6c4aa4dc01 (patch)
tree8d6d30abe1d0d1576e593ab4aaee2b4e29ca2077 /drivers/tty/serial/8250
parentf722406faae2d073cc1d01063d1123c35425939e (diff)
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 <ezequiel.garcia@free-electrons.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/8250')
-rw-r--r--drivers/tty/serial/8250/8250_dw.c6
1 files 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)
338{ 338{
339 struct dw8250_data *data = dev_get_drvdata(dev); 339 struct dw8250_data *data = dev_get_drvdata(dev);
340 340
341 clk_disable_unprepare(data->clk); 341 if (!IS_ERR(data->clk))
342 clk_disable_unprepare(data->clk);
342 343
343 return 0; 344 return 0;
344} 345}
@@ -347,7 +348,8 @@ static int dw8250_runtime_resume(struct device *dev)
347{ 348{
348 struct dw8250_data *data = dev_get_drvdata(dev); 349 struct dw8250_data *data = dev_get_drvdata(dev);
349 350
350 clk_prepare_enable(data->clk); 351 if (!IS_ERR(data->clk))
352 clk_prepare_enable(data->clk);
351 353
352 return 0; 354 return 0;
353} 355}