Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 671B2C7EE23 for ; Mon, 27 Feb 2023 02:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbjB0C21 (ORCPT ); Sun, 26 Feb 2023 21:28:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231475AbjB0C2I (ORCPT ); Sun, 26 Feb 2023 21:28:08 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9053020D00; Sun, 26 Feb 2023 18:24:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id E43B3CE0F25; Mon, 27 Feb 2023 02:09:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D236C433EF; Mon, 27 Feb 2023 02:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677463745; bh=YVuj1t6VKWFAH41UqMeidaZUSpdBhp8oxL3SpS3WuK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y0VUJfMiaJkGnoBHy1MBoHeuslauBeXgIbRI23I2TydCTL9mxaAEjEyK1urvQPi9K pFuxGGpgQMMAkKtMYbjEpnx29rGT2wuhOfhuw6h3sFHT2dIL7BEka8A4Gtn0O4rtzd x8nnmTh/Ij/zzi1BpsRtL4K7BIPmWjkhfxdNqlgyu1hNGSZFQMlOtv7uz3EMflqMzN hLH5BbWabmwMBwMlkQnuXhZPFglmUO9LTlNrFFNOxtxrrFw0PM3TGn/OmNa7kwnsZ7 LvDrIUT+NpZ6gT9m2yRpxl58h/5/A7uQHunxyPCjzFFIDxWA4MFwzRwjaOUTq+nitv U8CChmfoYyWDQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Roman Li , kernel test robot , Dan Carpenter , Wayne Lin , Jasdeep Dhillon , Alex Deucher , Sasha Levin , harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, aurabindo.pillai@amd.com, hersenxs.wu@amd.com, stylon.wang@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.15 02/25] drm/amd/display: Fix potential null-deref in dm_resume Date: Sun, 26 Feb 2023 21:08:25 -0500 Message-Id: <20230227020855.1051605-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230227020855.1051605-1-sashal@kernel.org> References: <20230227020855.1051605-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Li [ Upstream commit 7a7175a2cd84b7874bebbf8e59f134557a34161b ] [Why] Fixing smatch error: dm_resume() error: we previously assumed 'aconnector->dc_link' could be null [How] Check if dc_link null at the beginning of the loop, so further checks can be dropped. Reported-by: kernel test robot Reported-by: Dan Carpenter Reviewed-by: Wayne Lin Acked-by: Jasdeep Dhillon Signed-off-by: Roman Li Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index b4293b5a82526..68c98e30fee71 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2687,12 +2687,14 @@ static int dm_resume(void *handle) drm_for_each_connector_iter(connector, &iter) { aconnector = to_amdgpu_dm_connector(connector); + if (!aconnector->dc_link) + continue; + /* * this is the case when traversing through already created * MST connectors, should be skipped */ - if (aconnector->dc_link && - aconnector->dc_link->type == dc_connection_mst_branch) + if (aconnector->dc_link->type == dc_connection_mst_branch) continue; mutex_lock(&aconnector->hpd_lock); -- 2.39.0