Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6797387rwd; Tue, 6 Jun 2023 01:57:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4B4uwHdFCRdHUYavOhxMKWg/XKzcxCQZnQ+PLgMYvq5R6sMksHz2jnoCdfBqIAd4ObXQVZ X-Received: by 2002:a05:6358:1a9c:b0:123:26fe:3346 with SMTP id gm28-20020a0563581a9c00b0012326fe3346mr2477151rwb.2.1686041849627; Tue, 06 Jun 2023 01:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686041849; cv=none; d=google.com; s=arc-20160816; b=XWLCDrC0mPaZnxxYbcuH5hWHQkBY6OC685WyutpRmPw0afo+ly/oyDu+51YEvSC6fG MrAE+RTObYS/71ckx+RP9sFwEBTgbeSscX08fmqA4t2PurRhD9KfOSVHXZiZ/n1VPr1s Vtr3+vJx8Pggvd0ajq8lTHgH2gNMIqaM+ym41uhF245Hhu3C8cOPZrTj/eYkugd6lGSE Xh9k8EYs+LTTDi8pvrODYtvyRE2+e+64Z0kbBjHrwG0/qYHRR1RtisRMGWXC4NWZ42Tu N/i3muYAplbuRWxAD5YTdOMRi9Q3trLs3ytIQI8ImeOaFipm+Z/2XbYYRlxpbDlVxqIG 00gA== 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 :message-id:date:subject:cc:to:from; bh=5jXxzf5Xp9BVWVWnYgoJBz0SX1boM2W0DcxMW2I3wNg=; b=QeZwAUsg7daL7yu32ygAhzqdeNkVsMEXgjanOuzUuR7RsW0hMfKHzaflmWpglia1VZ 6UhgotETadHgUCy5sW/rhY1k4YOPI8oSvPgmMLLNXyVhdomxTTWWK51PMfMYiK5PPUla K/9rvvSQ5G2WSR/I2jX408evAoK4YKcD5L+C/msWosav0nqk7YExjDfGx4BDZfaaoiTu fhPHj9isajo95eRpsG75SVff044VWWioTBaeR0+RlXhZusdDBsevVqiK5JQ3DJwcafcO 51Xes6Y3yJm1V0on6EsGQRbP4VJLZ2yUzsuBQwir14fbIid9pD/rXOBZMhpQjPTIvoHX 8etw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s28-20020a63925c000000b005428de93a2asi7159382pgn.142.2023.06.06.01.57.16; Tue, 06 Jun 2023 01:57:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236041AbjFFIAm (ORCPT + 99 others); Tue, 6 Jun 2023 04:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236973AbjFFIAI (ORCPT ); Tue, 6 Jun 2023 04:00:08 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 481B4273D for ; Tue, 6 Jun 2023 00:57:35 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id DBF29180121FCD; Tue, 6 Jun 2023 15:55:28 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: Douglas Anderson , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter Cc: u.kleine-koenig@pengutronix.de, andersson@kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Su Hui Subject: [PATCH] drm/bridge: ti-sn65dsi86: Avoid possible buffer overflow Date: Tue, 6 Jun 2023 15:55:27 +0800 Message-Id: <20230606075527.155346-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Smatch error:buffer overflow 'ti_sn_bridge_refclk_lut' 5 <= 5. Fixes: cea86c5bb442 ("drm/bridge: ti-sn65dsi86: Implement the pwm_chip") Signed-off-by: Su Hui --- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 7a748785c545..952aae4221e7 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -305,7 +305,8 @@ static void ti_sn_bridge_set_refclk_freq(struct ti_sn65dsi86 *pdata) * The PWM refclk is based on the value written to SN_DPPLL_SRC_REG, * regardless of its actual sourcing. */ - pdata->pwm_refclk_freq = ti_sn_bridge_refclk_lut[i]; + if (i < refclk_lut_size) + pdata->pwm_refclk_freq = ti_sn_bridge_refclk_lut[i]; } static void ti_sn65dsi86_enable_comms(struct ti_sn65dsi86 *pdata) -- 2.30.2