Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752176AbdHHOuY (ORCPT ); Tue, 8 Aug 2017 10:50:24 -0400 Received: from m12-16.163.com ([220.181.12.16]:32986 "EHLO m12-16.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbdHHOuW (ORCPT ); Tue, 8 Aug 2017 10:50:22 -0400 From: Pan Bian To: Minghsiu Tsai , Houlong Wei , Andrew-CT Chen , Mauro Carvalho Chehab , Matthias Brugger Cc: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Pan Bian Subject: media: mtk-mdp: use IS_ERR to check return value of of_clk_get Date: Tue, 8 Aug 2017 22:49:58 +0800 Message-Id: <1502203798-31997-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: EMCowACXNDqfz4lZYma8Bg--.57475S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrur1fXrWUGr48Wr4kCw45KFg_yoWkKwc_Ar 40qF43ur4fu3Z8Cr9Ykr4SvryUKFZY9r10yayDKr4akry8WryDGrn0va9rGF97JFW2yFyU Aw4UXa47Cr17CjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnUl1JUUUUU== X-Originating-IP: [106.120.213.24] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBZAIuclQG9fTfwgAAs0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1167 Lines: 35 Function of_clk_get() returns an ERR_PTR on failures. In file mtk_mdp_commp.c, its return value is checked against NULL. Such checks cannot prevent from accessing bad memory. This patch replaces the NULL checks with IS_ERR checks. Signed-off-by: Pan Bian --- drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index aa8f9fd..54bb716 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -75,7 +75,7 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) } for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { - if (!comp->clk[i]) + if (IS_ERR(comp->clk[i])) continue; err = clk_prepare_enable(comp->clk[i]); if (err) @@ -90,7 +90,7 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) int i; for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { - if (!comp->clk[i]) + if (IS_ERR(comp->clk[i])) continue; clk_disable_unprepare(comp->clk[i]); } -- 1.9.1