From: Anatolij Gustschin Date: Wed, 3 Jan 2018 12:20:49 +0100 Subject: [U-Boot] [PATCH v2 1/2] video: ipu: Fix dereferencing NULL pointer problem In-Reply-To: <1514877937-24144-1-git-send-email-peng.fan@nxp.com> References: <1514877937-24144-1-git-send-email-peng.fan@nxp.com> Message-ID: <20180103112049.4504-1-agust@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Peng Fan The clk_set_rate function dereferences the clk pointer without checking whether it is NULL. This may cause problem when clk is NULL. Signed-off-by: Peng Fan Signed-off-by: Anatolij Gustschin --- Changes in v2: - move the NULL check to top of function drivers/video/ipu_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/video/ipu_common.c b/drivers/video/ipu_common.c index 96229da502..889085aa76 100644 --- a/drivers/video/ipu_common.c +++ b/drivers/video/ipu_common.c @@ -132,8 +132,12 @@ struct clk *clk_get_parent(struct clk *clk) int clk_set_rate(struct clk *clk, unsigned long rate) { - if (clk && clk->set_rate) + if (!clk) + return 0; + + if (clk->set_rate) clk->set_rate(clk, rate); + return clk->rate; } -- 2.11.0