Skip to content

Commit

Permalink
serial: 8250_dw: Add valid clk pointer check
Browse files Browse the repository at this point in the history
Commit ffc3ae6 "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>
  • Loading branch information
Ezequiel Garcia authored and Greg Kroah-Hartman committed May 20, 2013
1 parent f722406 commit dbd2df8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/tty/serial/8250/8250_dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit dbd2df8

Please sign in to comment.