Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp417313pxb; Wed, 24 Feb 2021 05:51:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJw17mI4mGfJn0QUivfRq1PY4vrIOJHtjxLHc7jLvpc2WNQnfOCDPLMScFXYjvY62rapSJta X-Received: by 2002:a17:906:3105:: with SMTP id 5mr31460845ejx.168.1614174711033; Wed, 24 Feb 2021 05:51:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614174711; cv=none; d=google.com; s=arc-20160816; b=PCic+LxIOpP1BKJxyhjp0R6CHJWHQLjRssXH4EAlAtgpNKHYSDhKhIhIqY/egwBozP 7VHXCN7RyzJ57ZeMZUpIF4L24JVf5vnLUtdWBiQDrwdiQvKqW30as9wO5RjgpHoGmS5y 7oCcC8uy4Tr8QQUoqpbeJ0qCrtqx1W5/nVD13058/HNHcQsOorcCeQGtiIpFV5xWdTLE cD4I37T1eSqZ3N9E83w+8urx5iueMaImgR0v6+W3BLB99wsIcuGM8GVCFlK0c8ZmKp5B Pejdqxbtc82faWO+qua3HD4VaK2r+SgpGbe4ZC/CnG47av8I4i9PZUta6j/8QG8SjNLn mpog== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PBNxH+w8NzhEg3ZCiKdgZAFvVJZE9mt/pqMGVAB4waw=; b=Pk1UffUglGTUEwxOhJ4SsxiAWnW0joHnjD9e5F14w3CoL97pYxOgB83H+uk8o8XqjQ 2lNDpYSowc3OkdH8YsgVXHaSHfSZMZFJJLiw2rBjc1j4Bx7wcCPQub6s1tmWzMPIao5x EHOZhG6YfTMa0xqio+IeVtQrHIqBHaPTrqvNonE+FoeGQj0FQIdBeXQBgGwlTtQh70j7 XoetMx7J4cGuWiujdhqNlnsioL1+5Pu/rD0UwixWKUIIoy2oQHB21lcg0ppGziKE0GzS ufEDLcLwz4e0+v8uOe0989p4GvyC7yv4ZsK2JMNjlvnmucmAKa2fQd3yH6QmvnoUF4GB 2PLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mABoQ9uN; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a36si1187606edf.419.2021.02.24.05.51.04; Wed, 24 Feb 2021 05:51:51 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=mABoQ9uN; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237719AbhBXNmd (ORCPT + 99 others); Wed, 24 Feb 2021 08:42:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:58442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235714AbhBXNFD (ORCPT ); Wed, 24 Feb 2021 08:05:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E5F664F80; Wed, 24 Feb 2021 12:54:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171246; bh=EomfylCSApmaTvl+siIcJT0taEri7bkI5Dnz8wQmmE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mABoQ9uNJ4N1RkJUm7MSqbpT1ohqu+G7EokN9qpijd+lIwK2rLisUIPHV4cx5wuHR zTHOfX/MQ8YeLGlvwBjqk2nG2gwUsMwRUFvPUiFyvaWFIdMZny/vZHUtxESmXhv+uS 7ELQlrwLMLxaiwT4Flo0iGZYjDyHg0Lnl+sqE+clpDygF00BYUB2gCmUJFQX4TWDcB rYwQ6nPVdwgnmW/PeQ+QPIAsBW+IGLYyxLvU0zZMBZGf0XGeo3leTyWhOHgkgG0fNQ CieAK8TAo+fE/SCEPkxXq14jfpVPpfRgH9Azh3gL9W9NNl4dQpo/vW6nb/EjaG+fkC bVLNqDKFyNe4Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Kazlauskas , Daniel Wheeler , Eric Yang , Anson Jacob , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 19/40] drm/amd/display: Guard against NULL pointer deref when get_i2c_info fails Date: Wed, 24 Feb 2021 07:53:19 -0500 Message-Id: <20210224125340.483162-19-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125340.483162-1-sashal@kernel.org> References: <20210224125340.483162-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: Nicholas Kazlauskas [ Upstream commit 44a09e3d95bd2b7b0c224100f78f335859c4e193 ] [Why] If the BIOS table is invalid or corrupt then get_i2c_info can fail and we dereference a NULL pointer. [How] Check that ddc_pin is not NULL before using it and log an error if it is because this is unexpected. Tested-by: Daniel Wheeler Signed-off-by: Nicholas Kazlauskas Reviewed-by: Eric Yang Acked-by: Anson Jacob Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index fa92b88bc5a13..40041c61a100e 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -1303,6 +1303,11 @@ static bool construct( goto ddc_create_fail; } + if (!link->ddc->ddc_pin) { + DC_ERROR("Failed to get I2C info for connector!\n"); + goto ddc_create_fail; + } + link->ddc_hw_inst = dal_ddc_get_line( dal_ddc_service_get_ddc_pin(link->ddc)); -- 2.27.0