Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp232115rdb; Thu, 8 Feb 2024 04:37:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDY7N6CCAXCX7QPZOzlqIWPruJvn33sATeap/93HehleARMueJ3G+5K0gYaKqd8HiCR+uH X-Received: by 2002:a17:90b:1881:b0:296:1ac3:c572 with SMTP id mn1-20020a17090b188100b002961ac3c572mr3871364pjb.13.1707395855165; Thu, 08 Feb 2024 04:37:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707395855; cv=pass; d=google.com; s=arc-20160816; b=Ow9S+vOKklFKyTyo+O4vMvXJxa6eyEZoe8gJmXSuxeXFv37mngXsPLmSipOXxCk3wj +N7wnSU3FPGPfyDfKaRHvl3YeC+iO07K9pXlSnl+u8C4EVFON3XsOfX7EizrG2vOkFJZ IVEqZE969aTbZWwHWnGJMoOLP/W8KhOHarTlG4sHHNPyPGQV6ywcpRMIv6HFSxVKHKBK Oilo7FJWmi/fYtTIVI2K/wV97y+y4KuXGN8m7r/EfjtZXs8agpuGzH+OZkjJ+gYFBMnF G6EH7fq/5AF47dAsVh0ENLUOhCAeEr/wGkMBBvDyVlFxmYGlBoDS+PDjtBURi/VECXet QtZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=a6n23J90H73uvSPoqHR6vZBsbQOBpnp/BJSxjanELLw=; fh=yJU8xEwBVeA2GnvJ+vvkcIcq8NWsQB7B4RdZWQjEl6A=; b=xdKjWwCe6NozndrjBeb+w4k2e3SJLLucWeR2stNoI/LTziHIMXNQ2IF37mO99LdcU8 AI+6ppN4skhKJp6x70n6V9D5JXWk7q6UuS8rNqBYiEJFYCsktpgN5aTECw2MrxmosKFs wBCPLEYHxUpqdXXP2NWU9csnCAH3BozYu2H/CjB88hIpQlJJBG1NlBwan9D0cQ66awqf 90iBtsyfobmEC+Go6MXBTM87+bQNWBbnhWllNo+voSUZHHi7MHRxE0nyrFzuQcnNXEH7 cQzuSzKO2220vh9ss6WNbt2Dh0KTuoQSqEkHjou3oMzw0zoYyu9582gYbQU4iVn7r+tN TQcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-58065-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58065-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWk8p4AHcsnIjbhjiDD6vg6psDk3fCPSo1BABYTZG8c1in7DYk8A3BvMGxHrwQSK561n4exeSzMms7hYUTdRSGo34exl3ed9I9/HwSM/w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id se14-20020a17090b518e00b002962d390c0dsi1326457pjb.152.2024.02.08.04.37.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:37:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58065-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-58065-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58065-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C5789282622 for ; Thu, 8 Feb 2024 12:37:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50DC676024; Thu, 8 Feb 2024 12:37:29 +0000 (UTC) Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E07C46F079 for ; Thu, 8 Feb 2024 12:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.54.195.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707395848; cv=none; b=X4nD47W8WQ/J+AKEit/CfZCtJ6Hy2UHxar7Z5roBF5v+tuVD2mYdR9MheeIgYinPeBvL2Z0OGkaltrUcPDmnL94Q6tP0K0dNuRghtBur1gm7drwd1i47mG1idE4rPz8SG+W4zp3DqtYWToxL5YKhp+92cdrhUKp4U4cJfZlY4Ck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707395848; c=relaxed/simple; bh=SMxSSIouZobaeMXDonh6APoF96Mk6tvwC3mgcseiygE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Q8hJkcjFhGc9AnINL+KrQ1nJY7OTRd15ZD7eJelPSQ88nwEu0GMfpccHHCm00baeNtzVS3LI0dOa4j7WXaGLpAj6yua68GV/lLwDJ9opRYKyrOZbYZKVUYkyHTK+/lD9U6cfLZaXVfQ5zPCE06lPCDnuxE8gdGmntRMHIuk2oeo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru; spf=pass smtp.mailfrom=fintech.ru; arc=none smtp.client-ip=195.54.195.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fintech.ru Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Thu, 8 Feb 2024 15:37:15 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Thu, 8 Feb 2024 15:37:15 +0300 From: Nikita Zhandarovich To: Harry Wentland CC: Nikita Zhandarovich , Leo Li , Rodrigo Siqueira , "Alex Deucher" , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Leon Huang , , , , Subject: [PATCH] drm/amd/display: Fix missing NULL check in dcn21_set_backlight_level() Date: Thu, 8 Feb 2024 04:37:11 -0800 Message-ID: <20240208123711.52333-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) On the off chance 'panel_cntl' ends up being not properly initialized, dcn21_set_backlight_level() may hit NULL pointer dereference while changing embedded panel backlight levels. Prevent this issue by using some of the existing checks for the similar purpose. At the same time clean up redundant tests for NULL in 'abm'. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 6f0ef80a00ad ("drm/amd/display: Fix ABM pipe/backlight issues when change backlight") Signed-off-by: Nikita Zhandarovich --- drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c index 8e88dcaf88f5..2b1b580541a8 100644 --- a/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c +++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c @@ -247,7 +247,7 @@ bool dcn21_set_backlight_level(struct pipe_ctx *pipe_ctx, if (abm != NULL) { uint32_t otg_inst = pipe_ctx->stream_res.tg->inst; - if (abm && panel_cntl) { + if (panel_cntl) { if (abm->funcs && abm->funcs->set_pipe_ex) { abm->funcs->set_pipe_ex(abm, otg_inst, @@ -261,15 +261,16 @@ bool dcn21_set_backlight_level(struct pipe_ctx *pipe_ctx, panel_cntl->inst, panel_cntl->pwrseq_inst); } + + if (abm->funcs && abm->funcs->set_backlight_level_pwm) + abm->funcs->set_backlight_level_pwm(abm, backlight_pwm_u16_16, + frame_ramp, 0, panel_cntl->inst); + else + dmub_abm_set_backlight(dc, backlight_pwm_u16_16, frame_ramp, + panel_cntl->inst); } } - if (abm && abm->funcs && abm->funcs->set_backlight_level_pwm) - abm->funcs->set_backlight_level_pwm(abm, backlight_pwm_u16_16, - frame_ramp, 0, panel_cntl->inst); - else - dmub_abm_set_backlight(dc, backlight_pwm_u16_16, frame_ramp, panel_cntl->inst); - return true; }