From patchwork Mon Jun 3 03:02:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Young Xiao <92siuyang@gmail.com> X-Patchwork-Id: 10972495 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B8DF6C5 for ; Mon, 3 Jun 2019 07:41:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E69728789 for ; Mon, 3 Jun 2019 07:41:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52EEE287A4; Mon, 3 Jun 2019 07:41:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C7B4288E6 for ; Mon, 3 Jun 2019 07:40:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7303E89688; Mon, 3 Jun 2019 07:40:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 20F9A894EB; Mon, 3 Jun 2019 03:01:29 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id u17so9711737pfn.7; Sun, 02 Jun 2019 20:01:29 -0700 (PDT) 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; bh=FVbLKJ7aHdVl9olP6rdiDo2FyvciQZ6SOLC15bFopUs=; b=lcQaLQam1jd6lw/rCVtlu2hWylZRQaaopQ6OzuUnmH5fEFhmFnHjgZ1BVWhnMRstbC k8d0FqXYrpPRSWjCy/E7oBIaPiZYlo+aH9jyn1oHvJBIoB7abhhil+YCVzgjYMfPpm7V VEERXhbyQFtbKufGPJbMXtDMmNR2rmMIZJL3Dia7/9FG/YLJMjoToC4guExNLI+u5qjy WVWjPzp+AAOhnIt/T/1Ed/zNK6MW/q0rcOT4HScFajp3QMSKVKjy5yZyqFspi53B/NHj bwnk0tbj0lfGPp0IS+98r3BtiPEpM+xiuGIQv1IXeolCii7OT/kACHS6tA9BieUH4XSG PK5g== X-Gm-Message-State: APjAAAUQoERSebLaFN7Ptm64MQ9S1XTgpTq/Burm01OiZKPINs8J9GMc DAJ1w+yz7AKheTNbKFVsItKa3xJ9qN+prw== X-Google-Smtp-Source: APXvYqxUNmDjQvpsM4PrbSHqDfF6Oikg3UOWVN0H3OuTPiIN+Wg0Uy4PR0jcHezKI0HJgfNmeklV8Q== X-Received: by 2002:a62:ee04:: with SMTP id e4mr27285689pfi.232.1559530888348; Sun, 02 Jun 2019 20:01:28 -0700 (PDT) Received: from xy-data.openstacklocal (ecs-159-138-22-150.compute.hwclouds-dns.com. [159.138.22.150]) by smtp.gmail.com with ESMTPSA id c16sm2244467pfc.69.2019.06.02.20.01.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Jun 2019 20:01:27 -0700 (PDT) From: Young Xiao <92siuyang@gmail.com> To: alexander.deucher@amd.com, christian.koenig@amd.com, David1.Zhou@amd.com, airlied@linux.ie, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/radeon: avoid a possible arrary overflow Date: Mon, 3 Jun 2019 11:02:37 +0800 Message-Id: <1559530957-11103-1-git-send-email-92siuyang@gmail.com> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Mon, 03 Jun 2019 07:40:43 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FVbLKJ7aHdVl9olP6rdiDo2FyvciQZ6SOLC15bFopUs=; b=JUxJ14EuMKRdzXXJnHjWCIA4R7kBcEmsSkQGdZH3lE4jYv715BnrdakjQqAJCSDOxf r2GEm4mvgKjfY57U2QZpUW3K/12ItP9/9YQb2NmTUd6SaiQmwpvgXJJynTZ/B6ZGCJSi pBwpTZ3DcSpHVkZZZfV/+bETZne+g8EmRI1F8oxbo9d4i93hzY7O0EeKoPgeAYzHCouH fCE321KyIc9QtGVLY1THGxJvgwkcQhbMWZVV3MncuHzMKU3G5KHF+mQx76SfczhJZFQd DQci1EcpJdg4D5/pTZADlFJs+s08N5QqrsrqDevtITPm83s2Beye6kyFOl0ttPo3r52j d4Rg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Young Xiao <92siuyang@gmail.com> MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When looking up the connector type make sure the index is valid. Avoids a later crash if we read past the end of the array. This bug is similar to the issue which was fixed in commit e1718d97aa88 ("drm/amdgpu: avoid a possible array overflow"). Signed-off-by: Young Xiao <92siuyang@gmail.com> --- drivers/gpu/drm/radeon/radeon_atombios.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index f422a8d..971c541 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c @@ -632,6 +632,10 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev) connector_object_id = con_obj_id; } } else { + if (con_obj_id >= ARRAY_SIZE(object_connector_convert)) { + DRM_ERROR("invalid con_obj_id %d\n", con_obj_id); + continue; + } igp_lane_info = 0; connector_type = object_connector_convert[con_obj_id];