Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3414361rwa; Tue, 23 Aug 2022 04:30:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ADUanQwZtWa3e7ko+Ye3Sk6VAKRln2pawPfU2/q06at73Yv4zECAWQnJEJ7bssuasfots X-Received: by 2002:a50:fe06:0:b0:446:bad:4b0e with SMTP id f6-20020a50fe06000000b004460bad4b0emr3356236edt.20.1661254233164; Tue, 23 Aug 2022 04:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254233; cv=none; d=google.com; s=arc-20160816; b=AVey/mzxDas3Cod/InfNhSZqyQcwK3ERttM5kEecnx6oEWX4+5aDYr+zOBjWvFUtf6 QHzFHiWt8Aw5EgvjUenMgrhW6Ki7oHG6sUzOBfmBi3keAfJwj8Y76G1g+rN/Oupe3jwW VVCKXFHqrykkrR6U2xYnfPGHzKyttserCw726D6e4X5hQy+/A55AbZTXZdsd1d+ZnlUr h2iWuaxSute3ZL1frqiXFL6Kiv8rd7EYVQO4k81QIiYM6SGo28kVjVjhTmkP4WtjARWt 6dfukqvFes0fgPiGNGB9TOePybNW6e5WP1UaeJeiupYrr2uAMqWu0hfS8fji3GhBTXxl F05A== 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=Ic+d9oqa3AyXWVWgJtDLEerw3K/SsHaTsc4OlLB9pGE=; b=tb0xeh5UnAxoA01wWd+yGxBOthV7N5DEk31j5LCyINNe7OkH2aJzCY813pnYO1aT1e q/iNZgpsIydfUO3fhE5wZH4ZbTmiYZ2kMwS3ebIFyBNXlT5ahXzlVVLTzNXz6wTD0VSc vJy/DuOxx1UgbDuVJdppSkyZ4hI7SIt9RziX1b4YjOFQxuRIBZT99QbG5T2FKc6FjGz5 eQ8MaWTH/tqy2VRLon9v2dLn0tYacE8iBrfu3K07yYMXOtuFQ890WgY5IqddgdoI4KlF 0jIC4ZAt6Ba+zgwIU0tXBow0FVDpDTZAp3Q9A2cfzeOww45putiITWfgdszLDV9LWMTR xobg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="D9jY2a/x"; 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 dm16-20020a170907949000b0072af95f96dbsi11340453ejc.70.2022.08.23.04.30.07; Tue, 23 Aug 2022 04:30:33 -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="D9jY2a/x"; 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 S1355108AbiHWKht (ORCPT + 99 others); Tue, 23 Aug 2022 06:37:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355096AbiHWKWv (ORCPT ); Tue, 23 Aug 2022 06:22:51 -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 1D22782FBF; Tue, 23 Aug 2022 02:04: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 3B9B6B81C66; Tue, 23 Aug 2022 09:04:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A5EBC433C1; Tue, 23 Aug 2022 09:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245444; bh=l18Qu+IXvPl5b9AOPNjTpkiodeySE+AZif4LocecDSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D9jY2a/xxr4wUdJhuNTEF+887vuuBGgdyLiDPCY9H9TFTDEUMrF5+6EQK55PFRIE/ BWMtoOzefdYlfFsoKug2epxaVw8SKrlQbw0147yF4E6VxEd4SkJyi1YsckBiViqQmL Jt5m4R2giH+MU6/bI+imC/0X+XO4HRWI4KZeLKO8= 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.19 081/287] drm: bridge: sii8620: fix possible off-by-one Date: Tue, 23 Aug 2022 10:24:10 +0200 Message-Id: <20220823080103.001961180@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 ea433bb189ca..c72092319a53 100644 --- a/drivers/gpu/drm/bridge/sil-sii8620.c +++ b/drivers/gpu/drm/bridge/sil-sii8620.c @@ -607,7 +607,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; @@ -624,7 +624,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