Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3404089rwa; Tue, 23 Aug 2022 04:19:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR40ZnvZ3OJBdaaFBlZHBrdFZlAhwIAnGSBDXl1ffPKfo5+BJm6tjeIXnfVVpIblpuBZx2FG X-Received: by 2002:a05:6a00:218a:b0:536:ec30:828b with SMTP id h10-20020a056a00218a00b00536ec30828bmr3973679pfi.10.1661253595277; Tue, 23 Aug 2022 04:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253595; cv=none; d=google.com; s=arc-20160816; b=bP/Y7w76vyoTY3KOG2iTQnv7bu0tU5paKeAqx8dFUNKk0ENAL1Df1vfTycKKmZEbVI gf3Jer/5PfK3AKUd2Ff8S1GjH9yTBK/Kx8tSjeMmvYv/hbknL3XU+rCqv9vg1D5wpXG1 2FEi3egG7TI8ts7PJRXzeZd+uHQX0YZys/V9h3OLU+JksR6d6x0Ql4crbFsqnDv4nJh5 1q6Gn18WrJZxhb4uN0nJAJQBUZiMF+vmk+K6yu5cu1L7P+Zrw5vurs9JCQgCwVmCpxVW LO49W7B7Dx3+38nQekO1d0N6oTE/6LH9AzEb3tyRIflxFWx/Ohp/DcDwDwCw3havg0VR Ddfg== 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=+vGZUdnrtFYcFQQs5bHsGuDVntx+UU32rJq3ablXUz4=; b=rmdtuZ8cBsBMoAGVNlInyt2yZo4knYmpl6Sgo8iHoB3XpgXuWxH30nyAdKoboV+y0E Ud7Lw9MQxIpp3HH14Kvb1jNKEDxfHB3w4PmrActueIATUdE/S11gEm3Q1SUXG8EFmajL wJTviHFthNv3ZxlvGUCf+/ezTBHNBv85Kkmzd1UBcPPBss6zy5VPkRRGBJ72Ic3xyHhH Jsldo7PF5A8o7Kr38L0B8P08OMCK0S4Y7sMUn09CRtWh8pPPDaHL+tDIWv7xQGWF41x/ b2DYzFaPEJc5AaLpcnlJrFlhF7TSKTSI8Jb5+Gmy/Grk14ZKuftU0WFVjFFOLMzRrc4+ 20iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2HfODPPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a17090a8d1000b001fb034f4938si9719529pjo.85.2022.08.23.04.19.44; Tue, 23 Aug 2022 04:19:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2HfODPPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S243187AbiHWJru (ORCPT + 99 others); Tue, 23 Aug 2022 05:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351767AbiHWJpa (ORCPT ); Tue, 23 Aug 2022 05:45:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EEBD7A779; Tue, 23 Aug 2022 01:43:08 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 71950B81C5C; Tue, 23 Aug 2022 08:43:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8B47C433C1; Tue, 23 Aug 2022 08:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244187; bh=VFtKmVcVHFihUMWJ0z4ZSZNShLPoexT9ifPT9YdIUEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2HfODPPp8sS9sTqnZQnI/iRv3G3jGLnZyebcSCV0S3LmsyzqKDr70zY9tAeCJ/T21 h0pbu6qaRYiFPbdyXHk7JKo269i6h/FmAExmlEmmtnKUyClxl3NKeZKvOEE1ODqi/h mgdSppgrmVw6BiON5QA0QgI3/CNXGxJ66Vux8Nsk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Andrzej Hajda , Robert Foss , Sasha Levin Subject: [PATCH 4.14 070/229] drm: bridge: sii8620: fix possible off-by-one Date: Tue, 23 Aug 2022 10:23:51 +0200 Message-Id: <20220823080056.229988262@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangyu Hua [ Upstream commit 21779cc21c732c5eff8ea1624be6590450baa30f ] The next call to sii8620_burst_get_tx_buf will result in off-by-one When ctx->burst.tx_count + size == ARRAY_SIZE(ctx->burst.tx_buf). The same thing happens in sii8620_burst_get_rx_buf. This patch also change tx_count and tx_buf to rx_count and rx_buf in sii8620_burst_get_rx_buf. It is unreasonable to check tx_buf's size and use rx_buf. Fixes: e19e9c692f81 ("drm/bridge/sii8620: add support for burst eMSC transmissions") Signed-off-by: Hangyu Hua Reviewed-by: Andrzej Hajda Signed-off-by: Robert Foss Link: https://patchwork.freedesktop.org/patch/msgid/20220518065856.18936-1-hbh25y@gmail.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/bridge/sil-sii8620.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c index b93486892f4a..9edb7af37d1e 100644 --- a/drivers/gpu/drm/bridge/sil-sii8620.c +++ b/drivers/gpu/drm/bridge/sil-sii8620.c @@ -628,7 +628,7 @@ static void *sii8620_burst_get_tx_buf(struct sii8620 *ctx, int len) u8 *buf = &ctx->burst.tx_buf[ctx->burst.tx_count]; int size = len + 2; - if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) { + if (ctx->burst.tx_count + size >= ARRAY_SIZE(ctx->burst.tx_buf)) { dev_err(ctx->dev, "TX-BLK buffer exhausted\n"); ctx->error = -EINVAL; return NULL; @@ -645,7 +645,7 @@ static u8 *sii8620_burst_get_rx_buf(struct sii8620 *ctx, int len) u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count]; int size = len + 1; - if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) { + if (ctx->burst.rx_count + size >= ARRAY_SIZE(ctx->burst.rx_buf)) { dev_err(ctx->dev, "RX-BLK buffer exhausted\n"); ctx->error = -EINVAL; return NULL; -- 2.35.1