From patchwork Mon May 28 15:49:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 137096 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2985264lji; Mon, 28 May 2018 08:50:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrX8FgMj21j5arwSzpOKeclx8pDEqmrtTLq48bmX6VdSnRUZjczXFk+cJXy2Lbbry7ihFri X-Received: by 2002:a62:a89:: with SMTP id 9-v6mr13781950pfk.112.1527522623675; Mon, 28 May 2018 08:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527522623; cv=none; d=google.com; s=arc-20160816; b=YS3XvpV8VLoqbzlxCHqazImjFWN3It9SCXEL4YetRiicsuqKxOaWofaO4YAm1pyroW Cq7iPGhJjGYGmT92BrYRn8so/uS+AtKct3P8dKaOyCd5uxQAIuJR1jgwI5xWYy0+r8/M 2joyvA7x2q7smSNXN5yrWCJYxSqUBGTPP8o/kD14wUwsuqkyOoyEw3fmJLcPxaOMnXq9 hSRApIEf68dtRV4WPnX+BaU7Q5K3owxuweTYqbc7sXaa+S5Lv7aK3KfCT1UBw3i3nvID YqBtQhC5M4HVbisZG4zzE01kEN6NYxFh3mmQU2qFjGcYavo5Z3t/dGF8w3YeJk3Skoyv sSwA== 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=d4M+2PfYscs2+lFZ+1YG8/TYFf7pzlMBk2vakgu8cv0gEF5PUjNa7MeFtdscce0YnU 7gmqh0QY7FMqeSh/tKkU9bKPNsr1Vk+73tgnWa992e5sRLI5Ttm+uvU5IPCfoge5ReVO o4KHRlyJRvWBZ62pRDmyzPLDmDD742jurWcGhIGyHIKF4f+3pEgGWOdFLNB6vgnlobln 0RcKmQZZHkSSsFmoyvW4irBFfk2Pell1o5dmjanydj64mHk5VFprfIZ9G1+aTStGqcWt XRJiVxkwXQgFKgVfnmXBQPmRoOLcu0E8HRjchxTv1uXXqMJBUWMcPejAzlnSJ5lQVPoW lBgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 f64-v6si31136869pfa.252.2018.05.28.08.50.23; Mon, 28 May 2018 08:50:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034985AbeE1PuV (ORCPT + 9 others); Mon, 28 May 2018 11:50:21 -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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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(-) -- 2.9.0 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);