Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2477913imm; Mon, 28 May 2018 08:51:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq864Cx0oyosCCsD9yZg0KCV9QwhwTK5UVP3wTSmvlte62PDZhefAUGt4UiQ2iOU3VODEHs X-Received: by 2002:a17:902:2d24:: with SMTP id o33-v6mr14201229plb.14.1527522662942; Mon, 28 May 2018 08:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527522662; cv=none; d=google.com; s=arc-20160816; b=iA6X5kPaTQ8cfW7cE7E9NRBfVleV2r3XVvtJ82fP0xCI7CREHFf1I68dq/Kd/Iea90 CM8yqi314F92GMAqfqyIyUZkS3DrWA2sv3HfW92feH7igmDsCjT15l3j4zYHLrMkbbcH UeIyIB2HI+nQseBd94ro/4LwM58mGae4pH3OS8W0A87Od84pmBGZOlu8W4bV75N4NSnx 9Qi4hjQQtqAYJqNaY0sbL3lNj4XgoNJD0URC1gco/yUcwqJOXlSzcd8+7xwhc/Nj6e2C oPKriobipfclLAQkbEPOyGQZL4xI2ym4Lfm/05CgKrcHnP7+ZX4pDfff1PPmej4D6hHH 2fZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=H3SmhPmzzcOQ11inlfmaSEJXmF3TAn2xeWCVh9jc5gU=; b=cyFSO34EJpkD1lksjtlGtHvwJLAEuuy8T4Oaf1Vjq7NnG+JLR6tsoBScAQIjUlSKM4 gcTJJSrVfY5MmLyjSS8yVli7RmTz1VVXRS/Ci5OAl4lUFROcJ+tEACXpJo9LS7Vn9G5p Uk+78if2v9aC1EN9PdUleO3PBaljUdvc1rMtMVK2539q/5Qr11gfgE97tx8AIO9vK9NG yHq+BHcMSZi8qp4jAivJn6KhO+RzyX96anW0y8P/+KDdIQdaGHF73IOXws1zeX9wHLXc Y7BBM548wvXvmje3BJpyE/h8OF1dAksEI1666G8PyNVXwrq3V7d1Bz+ZbuunXpA7Lp7m nwiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7-v6si29585011plp.304.2018.05.28.08.50.48; Mon, 28 May 2018 08:51:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034987AbeE1PuW (ORCPT + 99 others); Mon, 28 May 2018 11:50:22 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:35589 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034914AbeE1PuR (ORCPT ); Mon, 28 May 2018 11:50:17 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0Letrj-1g7NOV0VY7-00qgE1; Mon, 28 May 2018 17:50:04 +0200 From: Arnd Bergmann To: Fugang Duan , "David S. Miller" Cc: Arnd Bergmann , Fabio Estevam , Andrew Lunn , Troy Kisky , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH, net-next] net: ethernet: freescale: fix false-positive string overflow warning Date: Mon, 28 May 2018 17:49:46 +0200 Message-Id: <20180528154958.2684086-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:oiRpTflwG8qWTNHcqsccGwSsouw9oSGsXkiEPP06InkxR7rvH5d Zk8NlzfyPtdFJVaXApXdNSh+eQx2xUECQQo1l93JH31DxpFrcZdOhTCC6xTzhX8XuZTEKRf v/QAIwH2lweJjSdbVgQiKqqrDZdRORDw+3nIzTcEOvzUJmMP9sJuK4UplPquoBOHStxdD8m jaAfqxQffTbaxRo+6RsgQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:UnpHTsyLKj8=:pXkXjAWeCulxe8haz52UxO FZUzwfDBCMQaJn7Atb/C2wy1DTObwGcU9wxvTORIFm9pyN3hVeD0q+OvljuzOaLOgvVIdekVA 0djzEdoPJast2fB9d13wy+Q4mwbI0xEkruaoto0ec7VsCB0mYRQlBaxIKiMRhqLRvFFJNr7Nc TJPBrvjAurmZR1ynxGkXEN68R5iSceWVPi1QeLe9hYy1gopKFDzumrEAl30J+ICVAGwiQcBtd uKK2uTUJ9CYVREfFi0XglGTtO26XZjjQBkEJmZNCON9YHAzCMP6B2HxA/2ZH/ZxyNjD3945yG f6mFsmSZwt+NmFvmeCtOyvPOh795y0iVe7bKwZJ0hCYMX609hzgZZoM/pa5BtwC9sbgP20Qok Z9eqt0mET7eQS50wcI7cxyxKXfq6iNIYmeGK2dllJGgAUbShbQEAKwVRzCDGvpFy6c+x3T5Dm YcftJhelCndtDShQPUWM2VVJ6AeCFxQxrzWKGaruwkbcnwuXxhzJtDlidSyP/DgRCSyBeQkN6 l42wIyeInpZpAByD1WDgqCwgbWcWyhsOON3wKZSek0G7T59VfPJm7JrDY+g7s1VUzUc/qFW8+ k01kYCX8ImWlxxBsl4l6XgqC0h2A6ntmgbcvcqNnN+W/vSnnzsGBHwmiyvx4sO7frcrOh1QvQ zId4lgs8W5mAzn+NrX4YhzGybZjl8piDyB/s7FkgInQ57fJKMA49qZ0dsg4kKKv0iYwk= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While compile-testing on arm64 with gcc-8.1, I ran into a build diagnostic: drivers/net/ethernet/freescale/fec_main.c: In function 'fec_probe': drivers/net/ethernet/freescale/fec_main.c:3517:25: error: '%d' directive writing between 1 and 10 bytes into a region of size 5 [-Werror=format-overflow=] sprintf(irq_name, "int%d", i); ^~ drivers/net/ethernet/freescale/fec_main.c:3517:21: note: directive argument in the range [0, 2147483646] sprintf(irq_name, "int%d", i); ^~~~~~~ drivers/net/ethernet/freescale/fec_main.c:3517:3: note: 'sprintf' output between 5 and 14 bytes into a destination of size 8 sprintf(irq_name, "int%d", i); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It appears this has never shown on ppc32 or arm32 for an unknown reason, but now gcc fails to identify that the 'irq_cnt' loop index has an upper bound of 3, and instead uses a bogus range. To work around the warning, this changes the sprintf to snprintf with the correct buffer length. Fixes: 78cc6e7ef957 ("net: ethernet: freescale: Allow FEC with COMPILE_TEST") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index ab7521c04eb2..c729665107f5 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3514,7 +3514,7 @@ fec_probe(struct platform_device *pdev) goto failed_init; for (i = 0; i < irq_cnt; i++) { - sprintf(irq_name, "int%d", i); + snprintf(irq_name, sizeof(irq_name), "int%d", i); irq = platform_get_irq_byname(pdev, irq_name); if (irq < 0) irq = platform_get_irq(pdev, i); -- 2.9.0