[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <DM5PR12MB2469A884396F6018F8437E22F1F79@DM5PR12MB2469.namprd12.prod.outlook.com>
Date: Tue, 10 Aug 2021 13:38:23 +0000
From: "Chen, Guchun" <Guchun.Chen@....com>
To: Tuo Li <islituo@...il.com>,
"Wentland, Harry" <Harry.Wentland@....com>,
"Li, Sun peng (Leo)" <Sunpeng.Li@....com>,
"Deucher, Alexander" <Alexander.Deucher@....com>,
"Koenig, Christian" <Christian.Koenig@....com>,
"Pan, Xinhui" <Xinhui.Pan@....com>,
"airlied@...ux.ie" <airlied@...ux.ie>,
"daniel@...ll.ch" <daniel@...ll.ch>,
"Cyr, Aric" <Aric.Cyr@....com>, "Lei, Jun" <Jun.Lei@....com>,
"Zhuo, Qingqing" <Qingqing.Zhuo@....com>,
"Siqueira, Rodrigo" <Rodrigo.Siqueira@....com>,
"Lee, Alvin" <Alvin.Lee2@....com>,
"Stempen, Vladimir" <Vladimir.Stempen@....com>,
"isabel.zhang@....com" <isabel.zhang@....com>,
"Lee, Sung" <Sung.Lee@....com>,
Po-Yu Hsieh Paul <Paul.Hsieh@....com>,
"Wood, Wyatt" <Wyatt.Wood@....com>
CC: "amd-gfx@...ts.freedesktop.org" <amd-gfx@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"baijiaju1990@...il.com" <baijiaju1990@...il.com>,
TOTE Robot <oslab@...nghua.edu.cn>
Subject: RE: [PATCH] drm/display: fix possible null-pointer dereference in
dcn10_set_clock()
[Public]
Thanks for your patch.
I suggest moving the check of function pointer dc->clk_mgr->funcs->get_clock earlier, and return early if it's NULL, as if it's NULL, it's meaningless to continue the clock setting.
....
if (!dc->clk_mgr || !dc->clk_mgr->funcs->get_clock)
return DC_FAIL_UNSUPPORTED_1;
dc->clk_mgr->funcs->get_clock(dc->clk_mgr,
context, clock_type, &clock_cfg);
....
Regards,
Guchun
-----Original Message-----
From: amd-gfx <amd-gfx-bounces@...ts.freedesktop.org> On Behalf Of Tuo Li
Sent: Tuesday, August 10, 2021 5:20 PM
To: Wentland, Harry <Harry.Wentland@....com>; Li, Sun peng (Leo) <Sunpeng.Li@....com>; Deucher, Alexander <Alexander.Deucher@....com>; Koenig, Christian <Christian.Koenig@....com>; Pan, Xinhui <Xinhui.Pan@....com>; airlied@...ux.ie; daniel@...ll.ch; Cyr, Aric <Aric.Cyr@....com>; Lei, Jun <Jun.Lei@....com>; Zhuo, Qingqing <Qingqing.Zhuo@....com>; Siqueira, Rodrigo <Rodrigo.Siqueira@....com>; Lee, Alvin <Alvin.Lee2@....com>; Stempen, Vladimir <Vladimir.Stempen@....com>; isabel.zhang@....com; Lee, Sung <Sung.Lee@....com>; Po-Yu Hsieh Paul <Paul.Hsieh@....com>; Wood, Wyatt <Wyatt.Wood@....com>
Cc: amd-gfx@...ts.freedesktop.org; dri-devel@...ts.freedesktop.org; linux-kernel@...r.kernel.org; baijiaju1990@...il.com; Tuo Li <islituo@...il.com>; TOTE Robot <oslab@...nghua.edu.cn>
Subject: [PATCH] drm/display: fix possible null-pointer dereference in dcn10_set_clock()
The variable dc->clk_mgr is checked in:
if (dc->clk_mgr && dc->clk_mgr->funcs->get_clock)
This indicates dc->clk_mgr can be NULL.
However, it is dereferenced in:
if (!dc->clk_mgr->funcs->get_clock)
To fix this possible null-pointer dereference, check dc->clk_mgr before dereferencing it.
Reported-by: TOTE Robot <oslab@...nghua.edu.cn>
Signed-off-by: Tuo Li <islituo@...il.com>
---
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index c545eddabdcc..3a7c7c7efa68 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -3635,7 +3635,7 @@ enum dc_status dcn10_set_clock(struct dc *dc,
dc->clk_mgr->funcs->get_clock(dc->clk_mgr,
context, clock_type, &clock_cfg);
- if (!dc->clk_mgr->funcs->get_clock)
+ if (dc->clk_mgr && !dc->clk_mgr->funcs->get_clock)
return DC_FAIL_UNSUPPORTED_1;
if (clk_khz > clock_cfg.max_clock_khz)
--
2.25.1
Powered by blists - more mailing lists