[15/20] drm/tegra/hub: Increase buffer size to ensure all possible values can be stored
Message ID | 20230824073710.2677348-16-lee@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp993167vqm; Thu, 24 Aug 2023 02:23:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPul4ujnf6PUveamlOllhk7EoVqR23ZVHeFGIv8xwlrQlB78h+eOO0ttDAxIUD76ej/74a X-Received: by 2002:aa7:87ce:0:b0:68a:4102:e483 with SMTP id i14-20020aa787ce000000b0068a4102e483mr16614676pfo.14.1692868998696; Thu, 24 Aug 2023 02:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692868998; cv=none; d=google.com; s=arc-20160816; b=l//Etpi5oJoTRt0w/IC+xmb9YmuOwq34+JZw+tuKnDTGrOY9+3c57yasPHre5r2+i7 I3zQysOr0NAj2jPCcRZE94EkSCn3HtijERIsQWDa6BXc39GwNjX1SzOibgEtYyWVQt/I aLeGANcdTFAuNQi9l0rH6ZdY3F0SgKjcOOcUV/9k6gicwQXcCr7rpxwBiQthBk2sc3+c fZzSvmRPxyC2sD6CViY0Ppc25mPU0tGqmeyAtRNyKnpzt/fpHmGJaZITcz50YA2/Jwks ue1t42EWMTcqun2oOqE0QEk/mGyQLkr3K2fSqECZ2jv71a3f9uPJGzN+rftgnnjhXS5o YY0g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IlNynGSeOURPgIJCdxsLsJadJO5xK20ZGYnG1Vkj3oo=; fh=NO3tluWefgkjWetjZfvHxYh4xbs+LWa8Tdgdi23eFzY=; b=CQbk2kFBiDxzxoW3PaswmXfUnVXNT3TSQxpLSejhAJFJQ0GlUVCUb59kf+EmMP/hxN vxu01RbAmKag0V8iVqKwoUqGvunWE+aFzOfaCQa5/aXioa6CNXAHKpBqZFPUV+ctppWF WzS+eBWsYfc7wdzhY8xnLb8Nn26LXqKQIY1bNxQkMnOwcfzaDvU+oDNzk/djtA67HSKH eVwjZmsHoLH6EZ8/fqruXlITjotdeFpZP+IO1CR6WV+/BOnDFwd0UMhSwK7HLsnDPtfP BJ1bl5u4MKZGQ7zpjDjQKNAlU9azsXwC3QDNsVHPpRRJJn/9um/bFNQdnHpSkjwn5tsd aIXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u5ji2+9D; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020a056a001d1600b0068bbfe33f55si3962740pfx.404.2023.08.24.02.23.05; Thu, 24 Aug 2023 02:23:18 -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=@kernel.org header.s=k20201202 header.b=u5ji2+9D; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240511AbjHXHio (ORCPT <rfc822;kjyul0303@gmail.com> + 99 others); Thu, 24 Aug 2023 03:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240417AbjHXHiL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 24 Aug 2023 03:38:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65DACC7; Thu, 24 Aug 2023 00:38:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 04EEE65936; Thu, 24 Aug 2023 07:38:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42B0BC433CA; Thu, 24 Aug 2023 07:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692862688; bh=Ud+JmrQSf+WR8fLk9PtmUGKmnz/n+mzcTHuAf4DcxX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u5ji2+9DHanRfav04RicE1BpnqasiNzCcJCY2gklfVBpwKZTDHXBnfRI2zPvHMR6b EDhSsPp9uIbNp0XLq4wmsg5rQl1GVmwm+KGFyMv7ED3vMGkja+GQKQmvoOWTmaLiTf rkQwt73vqm4LSSOyqNdGHff79+P77BUQiGk54ItBMwFHwusnjsamjymWUp3I/tY8R8 pyqQhtTglLhNR1viLM6VVH7wuZSev3eBVvkF+7srRuni8wsseL4fMmlmlctOySpWdF Rzd7UzjZBnBztEE+Lr0XPWru9W5onfLE0NSPSduzJHZKqV5keWJTCIk2d0BcJNKQe1 hhXLhGInGs3SA== From: Lee Jones <lee@kernel.org> To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, Thierry Reding <thierry.reding@gmail.com>, Mikko Perttunen <mperttunen@nvidia.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Jonathan Hunter <jonathanh@nvidia.com>, Philipp Zabel <p.zabel@pengutronix.de>, dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org Subject: [PATCH 15/20] drm/tegra/hub: Increase buffer size to ensure all possible values can be stored Date: Thu, 24 Aug 2023 08:37:00 +0100 Message-ID: <20230824073710.2677348-16-lee@kernel.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog In-Reply-To: <20230824073710.2677348-1-lee@kernel.org> References: <20230824073710.2677348-1-lee@kernel.org> 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775101803595902345 X-GMAIL-MSGID: 1775101803595902345 |
Series |
Rid W=1 warnings from GPU
|
|
Commit Message
Lee Jones
Aug. 24, 2023, 7:37 a.m. UTC
When converting from int to string, we must allow for up to 10-chars (2147483647).
Fixes the following W=1 kernel build warning(s):
drivers/gpu/drm/tegra/hub.c: In function ‘tegra_display_hub_probe’:
drivers/gpu/drm/tegra/hub.c:1106:47: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 4 [-Wformat-truncation=]
drivers/gpu/drm/tegra/hub.c:1106:42: note: directive argument in the range [0, 4294967294]
drivers/gpu/drm/tegra/hub.c:1106:17: note: ‘snprintf’ output between 6 and 15 bytes into a destination of size 8
Signed-off-by: Lee Jones <lee@kernel.org>
---
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-tegra@vger.kernel.org
---
drivers/gpu/drm/tegra/hub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, 24 Aug 2023, Jani Nikula wrote: > On Thu, 24 Aug 2023, Thierry Reding <thierry.reding@gmail.com> wrote: > > On Thu, Aug 24, 2023 at 08:37:00AM +0100, Lee Jones wrote: > >> When converting from int to string, we must allow for up to 10-chars (2147483647). > >> > >> Fixes the following W=1 kernel build warning(s): > >> > >> drivers/gpu/drm/tegra/hub.c: In function ‘tegra_display_hub_probe’: > >> drivers/gpu/drm/tegra/hub.c:1106:47: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 4 [-Wformat-truncation=] > >> drivers/gpu/drm/tegra/hub.c:1106:42: note: directive argument in the range [0, 4294967294] > >> drivers/gpu/drm/tegra/hub.c:1106:17: note: ‘snprintf’ output between 6 and 15 bytes into a destination of size 8 > > > > I wish there was (perhaps there is?) a better way to annotate that i > > will always be within a given range. In practice this is always going to > > be smaller than 10 and even in future hardware I wouldn't expect this to > > ever exceed anything like 32 or 64, so 8 characters is already generous. > > I assume you could do > > snprintf(id, sizeof(id), "wgrp%u", (unsigned char)i); > > but it's perhaps less obvious than just increasing the size of the > buffer. I had the very same thought process.
diff --git a/drivers/gpu/drm/tegra/hub.c b/drivers/gpu/drm/tegra/hub.c index 1af5f8318d914..f21e57e8599ee 100644 --- a/drivers/gpu/drm/tegra/hub.c +++ b/drivers/gpu/drm/tegra/hub.c @@ -1101,7 +1101,7 @@ static int tegra_display_hub_probe(struct platform_device *pdev) for (i = 0; i < hub->soc->num_wgrps; i++) { struct tegra_windowgroup *wgrp = &hub->wgrps[i]; - char id[8]; + char id[16]; snprintf(id, sizeof(id), "wgrp%u", i); mutex_init(&wgrp->lock);