Received: by 10.213.65.68 with SMTP id h4csp473469imn; Tue, 13 Mar 2018 10:09:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELsUu9NLYq+Or3+T1IzGxVXFUvYl50/l2uXeG1xkpGiltI1/15eDXN6rStqzq2sKntcWRetS X-Received: by 2002:a17:902:6e0f:: with SMTP id u15-v6mr1232872plk.78.1520960942716; Tue, 13 Mar 2018 10:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520960942; cv=none; d=google.com; s=arc-20160816; b=A77ROq9PblauEUwX4rg1j3qZnpXKo1VRS6AXPjv54CEB81HJmueeMdD8/xmefQ+f8T aPLoB1j3DKSdwkRgNSeD2MIn/7nTpsSiT15v1pMiYvmgppEXRCSRP/uMRneCD4XyRYK3 hpKA2VPhAMAPizNNBq1gIYtJ1yiQY6Le4rElrs7fAInSrsQXrALWA8qINos6XP8gMHlR sdsKgiSIFblPN0rZK345kZXL/bzkej9Qa9d6AcgJU0anVckvG1Y6cCRTGNkfCbWolEPC /vxZGSbHJeapUTZ0pgFl9pZq7uDGDX+iSbue+Rq/FAMnvrVGu19LawQaca35QbWBXjv1 /83g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hpdMEFvE2MPgVB7+6mrjZ+6aAwevoLPcs1x/Y2mKsAQ=; b=CAAJyV6L+hhrC7AejGbuTC3nultNlIdcp2hxgk4A0oy5EAeqmvAij0zGXHHBFLyFyQ TDrKWCI4k3Wpf9QVU92MbxDYdeVFuf/oHr04Iqp+caltmeHYbNM8LLibgjSPuZPkU7Hh 4cyVCsPHsAtMwUZ4nHi7WhB5dWQhOyY+NJXQz4YM3z19GjcLAsGh/525uN8EzI2InNuK WrpbmDwTK2McgNjayUo0Nw43oSLuJdoXD2eSkweZi0iKuacz/6ckrbgurpjyK7ifp2DA xyV0HC+l+/hs/1U2nS/5m3TRTvRS48/+rpsWHc9Nw578F8ya27c9fKMtXXEOdzPhf67I +xiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si284850pgq.806.2018.03.13.10.08.48; Tue, 13 Mar 2018 10:09:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932483AbeCMP1r (ORCPT + 99 others); Tue, 13 Mar 2018 11:27:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57288 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932257AbeCMP1p (ORCPT ); Tue, 13 Mar 2018 11:27:45 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 720CC11CD; Tue, 13 Mar 2018 15:27:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Kahola , Rodrigo Vivi , Jani Nikula , Joonas Lahtinen , intel-gfx@lists.freedesktop.org, Dhinakaran Pandiyan , Jani Nikula Subject: [PATCH 4.15 010/146] drm/i915/audio: fix check for av_enc_map overflow Date: Tue, 13 Mar 2018 16:22:57 +0100 Message-Id: <20180313152321.396639946@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jani Nikula commit 72a6d72c2cd03bba7b70117b63dea83d2de88057 upstream. Turns out -1 >= ARRAY_SIZE() is always true. Move the bounds check where we know pipe >= 0 and next to the array indexing where it makes most sense. Fixes: 9965db26ac05 ("drm/i915: Check for fused or unused pipes") Fixes: 0b7029b7e43f ("drm/i915: Check for fused or unused pipes") Cc: # v4.10+ Cc: Mika Kahola Cc: Rodrigo Vivi Cc: Jani Nikula Cc: Joonas Lahtinen Cc: intel-gfx@lists.freedesktop.org Reviewed-by: Dhinakaran Pandiyan Reviewed-by: Mika Kahola Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20180214173840.25360-1-jani.nikula@intel.com (cherry picked from commit cdb3db8542d854bd678d60cd28861b042e191672) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/intel_audio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/i915/intel_audio.c +++ b/drivers/gpu/drm/i915/intel_audio.c @@ -754,11 +754,11 @@ static struct intel_encoder *get_saved_e { struct intel_encoder *encoder; - if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map))) - return NULL; - /* MST */ if (pipe >= 0) { + if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map))) + return NULL; + encoder = dev_priv->av_enc_map[pipe]; /* * when bootup, audio driver may not know it is