From: Tuo Li <islituo@gmail.com>
To: "Chen, Guchun" <Guchun.Chen@amd.com>,
"Wentland, Harry" <Harry.Wentland@amd.com>,
"Li, Sun peng (Leo)" <Sunpeng.Li@amd.com>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>,
"Koenig, Christian" <Christian.Koenig@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
"airlied@linux.ie" <airlied@linux.ie>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"Cyr, Aric" <Aric.Cyr@amd.com>, "Lei, Jun" <Jun.Lei@amd.com>,
"Zhuo, Qingqing" <Qingqing.Zhuo@amd.com>,
"Siqueira, Rodrigo" <Rodrigo.Siqueira@amd.com>,
"Lee, Alvin" <Alvin.Lee2@amd.com>,
"Stempen, Vladimir" <Vladimir.Stempen@amd.com>,
"isabel.zhang@amd.com" <isabel.zhang@amd.com>,
"Lee, Sung" <Sung.Lee@amd.com>,
Po-Yu Hsieh Paul <Paul.Hsieh@amd.com>,
"Wood, Wyatt" <Wyatt.Wood@amd.com>
Cc: "amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"baijiaju1990@gmail.com" <baijiaju1990@gmail.com>,
TOTE Robot <oslab@tsinghua.edu.cn>
Subject: Re: [PATCH] drm/display: fix possible null-pointer dereference in dcn10_set_clock()
Date: Tue, 10 Aug 2021 21:55:39 +0800 [thread overview]
Message-ID: <b652ceb9-9211-1a73-29a8-5469fe4485d7@gmail.com> (raw)
In-Reply-To: <DM5PR12MB2469A884396F6018F8437E22F1F79@DM5PR12MB2469.namprd12.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 2811 bytes --]
Thanks for your feedback. We will prepare a V2 patch according to your advice.
Best wishes,
Tuo Li
On 2021/8/10 21:38, Chen, Guchun wrote:
> [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@lists.freedesktop.org> On Behalf Of Tuo Li
> Sent: Tuesday, August 10, 2021 5:20 PM
> To: Wentland, Harry <Harry.Wentland@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; airlied@linux.ie; daniel@ffwll.ch; Cyr, Aric <Aric.Cyr@amd.com>; Lei, Jun <Jun.Lei@amd.com>; Zhuo, Qingqing <Qingqing.Zhuo@amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Lee, Alvin <Alvin.Lee2@amd.com>; Stempen, Vladimir <Vladimir.Stempen@amd.com>; isabel.zhang@amd.com; Lee, Sung <Sung.Lee@amd.com>; Po-Yu Hsieh Paul <Paul.Hsieh@amd.com>; Wood, Wyatt <Wyatt.Wood@amd.com>
> Cc: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; baijiaju1990@gmail.com; Tuo Li <islituo@gmail.com>; TOTE Robot <oslab@tsinghua.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@tsinghua.edu.cn>
> Signed-off-by: Tuo Li <islituo@gmail.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
[-- Attachment #2: Type: text/html, Size: 5326 bytes --]
prev parent reply other threads:[~2021-08-10 13:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 9:20 [PATCH] drm/display: fix possible null-pointer dereference in dcn10_set_clock() Tuo Li
2021-08-10 13:38 ` Chen, Guchun
2021-08-10 13:55 ` Tuo Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b652ceb9-9211-1a73-29a8-5469fe4485d7@gmail.com \
--to=islituo@gmail.com \
--cc=Alexander.Deucher@amd.com \
--cc=Alvin.Lee2@amd.com \
--cc=Aric.Cyr@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Guchun.Chen@amd.com \
--cc=Harry.Wentland@amd.com \
--cc=Jun.Lei@amd.com \
--cc=Paul.Hsieh@amd.com \
--cc=Qingqing.Zhuo@amd.com \
--cc=Rodrigo.Siqueira@amd.com \
--cc=Sung.Lee@amd.com \
--cc=Sunpeng.Li@amd.com \
--cc=Vladimir.Stempen@amd.com \
--cc=Wyatt.Wood@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=amd-gfx@lists.freedesktop.org \
--cc=baijiaju1990@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=isabel.zhang@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oslab@tsinghua.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox