Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3420373pxt; Tue, 10 Aug 2021 03:18:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGy4WyJEqSz71Vurs2ti92aUC1WdEZoxausavMbYVOhc0x3EaCdMlU4kKPEJaAoPWN7xNU X-Received: by 2002:a17:906:fb09:: with SMTP id lz9mr11751634ejb.123.1628590684642; Tue, 10 Aug 2021 03:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628590684; cv=none; d=google.com; s=arc-20160816; b=eX1yVotcCmkE/OU7wBtP72tF7BUJE2HaJoOR3FpeMHxhXyPyMoFQspV0NTbmWc8Y/L 7iWUrmF19hLb/gYeeu+JNYbdtJAoOmAWa+FnDKOttWYgT7ry9Nlm+uRngIskvF0B93XJ jQKBy/waeu9DkBVOSAW1FkJXXFwkK4vPyGS0gzihd/38wz9K3KAM6kzGMPdv7sz2pVmc 0Og4Bb7JYtHjED/FXXrYhReMoWbKRFbgfsx+NzzZKNqiLiPFQCO9YAIuB7nTcn2FLUSS tKgTu32LKAkmb8KOxCv2DB7sSQZmUuXITrzvVZPetIfXfe40Wzzdbr2H0eaT75PvlQPr RwPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=brqLZCbNQX023f2oFBB+a/r7LFx6HehzzWG22oXEkSg=; b=vv8MMbNQbP/EiYrLgo+EL0br7oHqDIdkFCGwdTYX+pSsAuJtfzFjiyGLRY49dLZoIT G9B6Uk4pjg/GVHMRlX7Jd2PVNXXN+812l58MSB2o7BCJ24opD59+JRCCXmgK7O8eiwT3 fCFe4uEHK7VoBX2w7jVbIyxXxa1E2HidnJiHaJIVDB+1f/4rH1eKYPifod+P/rkkDc7Z FW9eFPro2W/sv+PsUqW0KKx0zYk3b85OQrE53CT8DRLEBC4dtY0v78md5sz7oQhgndJV pSLIgqr3050jB3fb3vJH8Ac7YOWB74qeAWomz8bD2FjnJDB/t/cpi1gltegilTvMBT+i n4Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JKvzgIiT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si20415683edv.399.2021.08.10.03.17.39; Tue, 10 Aug 2021 03:18:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JKvzgIiT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238920AbhHJJVo (ORCPT + 99 others); Tue, 10 Aug 2021 05:21:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238887AbhHJJVB (ORCPT ); Tue, 10 Aug 2021 05:21:01 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FD4BC0613D3 for ; Tue, 10 Aug 2021 02:20:40 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d1so20163791pll.1 for ; Tue, 10 Aug 2021 02:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=brqLZCbNQX023f2oFBB+a/r7LFx6HehzzWG22oXEkSg=; b=JKvzgIiTzcBqwg8ACnj0GipSsgk9xixnD5PD7m2fJsCSnqXajAUG6TDP+uk802rqk4 +EDD+8PnheygcYpqQpUoZLMzwqMr6yrFIfmFTvMucW7yiDKmlsLOQU4No9g4CtfndePZ NC5exEpwNbwhTJtB5gzYqDdnsin1f7qESSCe8hvipdRabxjGIvNTDt2d8gxrFhObVXWv j3UhnjFYaYYkEFX5xaDHnSoWV3tHBMQWNmGD6ko2/14NiFjHE+biawe8ZdFJsyv7uFsV PGyGXm7SWsBp/UIK92EpieqKRdMj4i22hOjWn1Yc+L89sYocyhMsCOD8ikpapnJspgdc EVwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=brqLZCbNQX023f2oFBB+a/r7LFx6HehzzWG22oXEkSg=; b=r8+hi3AqCtgkkIu16PMM/OHwHOODAQdq450modEeXeT5p1GWTRR+2a8Uy8TPcXq/8R 7AhvFaZ2Kt5W0yQmNfnOYjZKoqebjlyJWYWEUukjz/LoTLcQ78TklX0F/VoMeDEZ+IdC J9z10U97/bXguCITXyyrD2DgDHVFm2QePTetlhc/quOSJ+G9lkH760X1K1Rv1vEe1DWq byUw8sFpPuGvJmmZPG2IX0y2zgbwzP+HdjBH0z286diB3cnZ81kd7fKsAI29Jlf50wVO Zs771N7vL1krJK847ltckzAZzv3Iefe9zKz3NhrC+dRVphVlXLRIKlsompYwWiF2hPWZ ESow== X-Gm-Message-State: AOAM5324eTM1s8s0AteEQc6NoQtteh0XRwA9DCAIVOLunWUwFr78L+B5 hJ8Re8079MxTzvjtWmdkjOY= X-Received: by 2002:a63:6705:: with SMTP id b5mr56600pgc.69.1628587239810; Tue, 10 Aug 2021 02:20:39 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.40]) by smtp.gmail.com with ESMTPSA id k6sm8052139pjj.52.2021.08.10.02.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 02:20:39 -0700 (PDT) From: Tuo Li To: harry.wentland@amd.com, sunpeng.li@amd.com, alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie, daniel@ffwll.ch, aric.cyr@amd.com, Jun.Lei@amd.com, qingqing.zhuo@amd.com, Rodrigo.Siqueira@amd.com, alvin.lee2@amd.com, vladimir.stempen@amd.com, isabel.zhang@amd.com, sung.lee@amd.com, paul.hsieh@amd.com, 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 , TOTE Robot Subject: [PATCH] drm/display: fix possible null-pointer dereference in dcn10_set_clock() Date: Tue, 10 Aug 2021 02:20:04 -0700 Message-Id: <20210810092004.291429-1-islituo@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Tuo Li --- 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