From patchwork Mon Dec 4 14:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10090581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D345260329 for ; Mon, 4 Dec 2017 14:54:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5ED728E41 for ; Mon, 4 Dec 2017 14:54:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAC0528E44; Mon, 4 Dec 2017 14:54:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 661EF28E41 for ; Mon, 4 Dec 2017 14:54:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D47C96E369; Mon, 4 Dec 2017 14:54:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D7F96E369; Mon, 4 Dec 2017 14:54:45 +0000 (UTC) Received: from wuerfel.lan ([149.172.96.106]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0M6RPb-1fJdfI1FAx-00yT8g; Mon, 04 Dec 2017 15:54:39 +0100 From: Arnd Bergmann To: Ben Skeggs , David Airlie , Arnd Bergmann Subject: [PATCH] drm: nouveau: use correct string length Date: Mon, 4 Dec 2017 15:54:26 +0100 Message-Id: <20171204145437.621446-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:5iUmTLIeR5X8ZpdbxHeJ0TULOHi13Ccr+yZGrcDN3AHiv4GavCV sGgy8gzN6L4EcCpSeu/7cGtm4yrlitIftwLlpmsySP8mRCaJUtlD9D7tlq1eN/UfwDFMOFj zJvxdo0dCBejpepRBrBDiXTIgHzUc/3pgiWKTalDoKLpQ6jUbGNxLErga4Xg2GieXc2AjZ/ vxVpvovdEDL7axyNi3h1A== X-UI-Out-Filterresults: notjunk:1; V01:K0:Zz6Duh4BhNQ=:IHsLCOIfNFWPvKdEuE7Vdo M/Khtl8AyrbePTulXQgwqVgKwL4D8k234B4M5Utd/Scp1P3HKHpyd49f5waDCRwcAsJm5mQfy MoxSem2sO6kAOjG2WKkTRwJeaJU7yxFOCw4FWIHb9gTM1Cr2Ft6KEKTcEmmSMBn/cHrYfmD5A 87F+28ZLLe/A81DNbPs0tBv62SKNMTYgJYvhYP8WA7ipv2R24FzHo6WzKVSWPbDOKmqPtgYIn d0j8ok/GdT1ksEYsuh0efn1DmAbh0Z1dKXLYaROpJI4lWKVu3vTBh4ItnezAfmSeNCXkgNsaD pVdpGEEjExMiXct/qhWuia2Zg2/un2W8BcSumf/kTEvk9ybeZKQd6jBsq9QE0qrXkSNHOSwfb ttGOLwK6wMAHMEGLtkaw/zgK9Jxn/SUt6f3fVvk7bufZ3vLIY4/Ghsriv5UdP9re2FD5OYfSY mrF0SbVlP8NLW3Fbtcx+VhrZ3AbO/4d88DY/DOiniUnNkWm0/I82eq8WfHp6b7snxVMSQ9mbl q5srXHP3XyEKpq1ir80oUR7apfs3jq4HLHZVQ5oHiwrP8D/YmL93Mm1E0nG07thDw8mHeh0md nOt/DxtjFK7v6anlveUt0OUitwu8MbCWKGmjD9hhBo7fhqFd7QgP9vdM52dGJP09lf79vHTO8 xIVPjFCsQNXaGYzs7qfRlRJwEWmD/V/bnwC6bXJPNFZIm57mxB+BZ0a5+kzy4OACnx0zA4gDh 8MDjzP/bxhicV/uOPN5oc6mdeo//myQtHecvEQ== Cc: nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP gcc-8 reports drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c: In function 'nvkm_perfmon_mthd': include/linux/string.h:265:9: error: '__builtin_strncpy' specified bound 64 equals destination size [-Werror=stringop-truncation] We need one less byte or call strlcpy() to make it a nul-terminated string. Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c index dde89a4a0f5b..53859b6254d6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c @@ -462,7 +462,7 @@ nvkm_perfmon_mthd_query_domain(struct nvkm_perfmon *perfmon, args->v0.id = di; args->v0.signal_nr = nvkm_perfdom_count_perfsig(dom); - strncpy(args->v0.name, dom->name, sizeof(args->v0.name)); + strncpy(args->v0.name, dom->name, sizeof(args->v0.name) - 1); /* Currently only global counters (PCOUNTER) are implemented * but this will be different for local counters (MP). */ @@ -514,7 +514,7 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_perfmon *perfmon, "/%s/%02x", dom->name, si); } else { strncpy(args->v0.name, sig->name, - sizeof(args->v0.name)); + sizeof(args->v0.name) - 1); } args->v0.signal = si; @@ -572,7 +572,7 @@ nvkm_perfmon_mthd_query_source(struct nvkm_perfmon *perfmon, args->v0.source = sig->source[si]; args->v0.mask = src->mask; - strncpy(args->v0.name, src->name, sizeof(args->v0.name)); + strncpy(args->v0.name, src->name, sizeof(args->v0.name) - 1); } if (++si < source_nr) {