Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3091076rwb; Mon, 15 Aug 2022 17:54:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR5dqVu079uQmwa1AZV61q6kA+dKumtuuKV8w96+5tL9aUFIgDzXePsrSVmANtxe+t3slQ0z X-Received: by 2002:a17:906:8461:b0:730:a43a:9981 with SMTP id hx1-20020a170906846100b00730a43a9981mr11637107ejc.552.1660611196690; Mon, 15 Aug 2022 17:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611196; cv=none; d=google.com; s=arc-20160816; b=tWL94RhLw6E2POr8a+9WDmLCpmAnAzdU3+JylyYNH22lWOzf3FehbEMnxujUqkFTS2 Q8s8FGCFbR+oF+IusWI3LT+YlgRzH0JyYcb3l+ueSL8tdkm8a6wZxvKQdQhyuKOTxJu9 nDFKtIedXHFAa2mdvomgUt6Q8L+OQd+pK77/Jzk7Jyqi2Coovypg7IyPp9Yv3F+MISJ0 86f3m5FIVhZ5H3UmNOeJfPsQ77tZghYkutBqZZvQcjKwKKCjEt1OKvoRRc+bx/iuP/cr Hllso63AFEhVD7Inx+hcDDPCw6XiRWwqkFcHNtvGAPWIrFeW6zKiq/8jnZazgpMNnlqG WJpg== 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=0S/2jr7D9Hp3WGoVJegjut78QUeWaPIcn8ndPPWBqHE=; b=UkrZnyPA+12Aqiif/cWRzIQ3QNkyAWf8kC66itTjbjVsY7NGZdVSKYrYmdovog35JH s8DjdqavPpw6avcmGQDW9HOth13q1SZiqt7je1Ru6qXM13E/WzDZ54ZKt6emDY3d9scq LW2HnRU0YuwX/tAuk07/DCQP/dOpV0oT83mBJmjQ8hjW9UzenSQN6A1r57rHtE0oP5wm o5BAio8fQmqox23X93lPWoui3j5J/2X5Np3GPwuqU2am/RPvyVl4VbuHiiZvW41U+dIt cKN42LRCLPL5hBk0MJNmlf2Nxxjl2gx2/EbUQOBVn9VYL9dG0zkcRULNrnBqsq98g7Qo f/UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EdrIiKBg; 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 he7-20020a1709073d8700b0072b21f7a839si10506687ejc.238.2022.08.15.17.52.51; Mon, 15 Aug 2022 17:53:16 -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=EdrIiKBg; 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 S1354105AbiHOXtl (ORCPT + 99 others); Mon, 15 Aug 2022 19:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243255AbiHOXnp (ORCPT ); Mon, 15 Aug 2022 19:43:45 -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 3069386893; Mon, 15 Aug 2022 13:14:00 -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 DDCB9B810C5; Mon, 15 Aug 2022 20:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D47CC433B5; Mon, 15 Aug 2022 20:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594437; bh=LZk7gSWpaSoUsHd/k9TE2xG/PGVAIeKrKwCihr/MDmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdrIiKBguDpaDDfOS5jWhwUWrr1lfgxux8qmJXOIAnMWMrchon//ugCFs5zaa8J2F pkhbJqPF/aUzmyELGBLjFjh8jnW13AIiMJJNiopepe18bZYf1mPOf8RaCiyh0FMOuX 7jFGn4uWWwiHOrvuN8SfXb/mEQ9g4oCwLM8IfLwE= 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 5.19 0440/1157] drm: bridge: sii8620: fix possible off-by-one Date: Mon, 15 Aug 2022 19:56:36 +0200 Message-Id: <20220815180457.223749205@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 ec7745c31da0..ab0bce4a988c 100644 --- a/drivers/gpu/drm/bridge/sil-sii8620.c +++ b/drivers/gpu/drm/bridge/sil-sii8620.c @@ -605,7 +605,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; @@ -622,7 +622,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