Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1978134pxb; Fri, 5 Mar 2021 04:37:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwM5ItC+mGa9wMdxYyj7avEwegT6gqRYq3c4hRoRduRGF2sZSgAVbr0CaI+VDO0Yup0NKtJ X-Received: by 2002:aa7:d296:: with SMTP id w22mr9221396edq.150.1614947867650; Fri, 05 Mar 2021 04:37:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947867; cv=none; d=google.com; s=arc-20160816; b=FYxXG5MFF23oupqyPfFcEV7DBhBQWnVoTzNl2o/3OyDe9ZFwvW5VuqokQBTr4ULbuC b/2p0itclMi0mLCYWWG4kaI6hxTwA16HY5nO8lf1y4/kqRPsipNX0T2g7K5ExYvuLpIi qQGNoieXrlew7kzH3U99yyeIcEXjAYlpf1wXM7H5nziKZVgRxrtWzc9sJczxmAErIr5j W+rfV52/GXg2YPseCXjazzKVNJ3IhLLIRLN+KtlXOqwDeuSomHWCv43FS1tT2GibD0lw kOi4F13Fbi1Z/f9orLRSFsj67zWMVnfX3UFvdwwu4HekMB2iIfjPj0SYlJsacAKxDQHL sgmA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NeZtDLC90YfdMUVCNl9zIua2J7s332yMAYfNWrcElvM=; b=iKEqHRf4xHRtUi9HR4HYVPLgU0mMDp5eNbHBYi19nQR7FpUtIsqurZnv5vzlzkQh4n qMhb6wjaMZhK3pHZ8J02pi1aldLsETPiL4xcy1tqQGhKS8VeKld/NIrSVzifC6Pykkf/ cWoprVOL+ynIjsjz+ZU0ckwbOce5bR3EtMi26I7WGejILFQVpGK5SSCPs3A/gNK9dQq6 W8E2FlRqUnBoXorWBm5PJxd5JtAPEBmQvwiPp4hRRrB8Koojq1WRzLruK8pYcacd8g1H fvbheYb7c+TEoJ/r/Roxux+RZiT9iJZjbxoUvfM/NYPjUIuYEmyE/dh0P3yxRg1BogEX NN+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bXTlT+23; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu13si1184799ejb.588.2021.03.05.04.37.24; Fri, 05 Mar 2021 04:37:47 -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=@linuxfoundation.org header.s=korg header.b=bXTlT+23; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232741AbhCEMfS (ORCPT + 99 others); Fri, 5 Mar 2021 07:35:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:46402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231860AbhCEMen (ORCPT ); Fri, 5 Mar 2021 07:34:43 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 510676501D; Fri, 5 Mar 2021 12:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947681; bh=/KBQUc3XBQeTdmbwSV/TnNC2PL+nXl0zvygNZc+Jvlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXTlT+23k2cbt5j9HHoDq0F/mXLuo5h5yZ328uMFC/dJe8c9zVqGS0JGcjOF4wA5i PpMpozYm7kwlguE+KhSA5nTHm9LkdQMi0LQtXU3eDCJ101NPxVpG2tr8sytYQbTlmX 6JsCKFu71vbEbyZ5zC8aVMBTjXMB7zcpYoaCUgIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Wheeler , Nicholas Kazlauskas , Eric Yang , Anson Jacob , Alex Deucher , Sasha Levin Subject: [PATCH 5.4 45/72] drm/amd/display: Guard against NULL pointer deref when get_i2c_info fails Date: Fri, 5 Mar 2021 13:21:47 +0100 Message-Id: <20210305120859.550735603@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120857.341630346@linuxfoundation.org> References: <20210305120857.341630346@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 fa92b88bc5a1..40041c61a100 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.30.1