From patchwork Fri Jul 14 12:07:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 107800 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp894802obm; Fri, 14 Jul 2017 05:15:13 -0700 (PDT) X-Received: by 10.98.67.147 with SMTP id l19mr4895644pfi.198.1500034513392; Fri, 14 Jul 2017 05:15:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500034513; cv=none; d=google.com; s=arc-20160816; b=OWI9oyzFviM+Pbw49zz1W1O/QmN1ens7dVVrtMrpu4aTueUAuQ6+m7+Bx847Wrk25V tDgdLbarrD2h6V1NbQZeQi9sPsWsmC+xTVlvBH3vfMDa8US2XO57KDxOE33Pp2nq5YkK FACkBSBV2IXS+dPCgQBh4cnPJwaez3fA+yoJm6MqVWHQXM/ospq4XjQifrb+K2q3iVog POch8iVXoZhRjzZ8Sbj07twEbXnSHvg7zU2eU5XgwzdMPyFsBDbuNVOsw10bSru/2DdE na9fQTkP0HL5dF1nxbVMad2iulEgOBH2u+Yy78RV2/TFyC/2GlCW5C93pXw96tUpzGt5 L/Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=9SmMJzqNAA2+mHEZD+xBB8z54tIyTcfL2M1NM8E/Qp8=; b=xJ+mPWqhsH2Ti5DiweHlKtCHoWY9k8PKu/WKdmi30h+o5nal7/gxePseRFa9zlA2Mk ChFHqHSBGDaPzWsvTx9Qd1xNP2PKJMEnkWmEanKpCbwPDnu1YDywA9hltxVTc3FqJcOw 4zfAJWVbpO7NVmSMr0hAhyWKUVE+HRWJeenpwyU+Wa1XZPMwsaP+pzRyi+mOF8J2WueR lNuQdojwYKAXMidvDjztQzqnMcNv+am3qxjz2oz5Yi3vQow5AkWDSYb237jZwmKcwHaF Uac1qXVOkX/rg2kvSyHVZD0ctFA3FUG9YYmTXg3aXQ9d6XiQ3CMGItxagfWXW9iIMIWu gsbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-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 i14si6123201pgn.378.2017.07.14.05.15.13; Fri, 14 Jul 2017 05:15:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-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-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932299AbdGNMPK (ORCPT + 1 other); Fri, 14 Jul 2017 08:15:10 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:61136 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754032AbdGNMPE (ORCPT ); Fri, 14 Jul 2017 08:15:04 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0LcOxi-1dxrhI0gjO-00jrbF; Fri, 14 Jul 2017 14:13:34 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Yishai Hadas , Doug Ledford , Sean Hefty , Hal Rosenstock Cc: Greg Kroah-Hartman , Linus Torvalds , Guenter Roeck , akpm@linux-foundation.org, netdev@vger.kernel.org, "David S . Miller" , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, x86@kernel.org, Arnd Bergmann , Leon Romanovsky , Adit Ranadive , Or Gerlitz , Steve Wise , linux-rdma@vger.kernel.org Subject: [PATCH 22/22] IB/mlx4: fix sprintf format warning Date: Fri, 14 Jul 2017 14:07:14 +0200 Message-Id: <20170714120720.906842-23-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170714120720.906842-1-arnd@arndb.de> References: <20170714120720.906842-1-arnd@arndb.de> X-Provags-ID: V03:K0:gMjun5g3fdCRxfc98hQYjr+zsYVJMpwVreWDm/jffvxyDGpfZDx nPL/48N99eb52FYQAC3yI6PLw4NHNnqkMWLWojToMR0zRGji121aZGCWb8RuT/oWTWmGvRw Y8A8BIt2SweWEtPkuOxguObOtGnKe2amh+F86lCEf2y970dUYpAvJYmCK6jFGCOb4SQ2WnG 1UwVAk/caVJZ+M2dosqvg== X-UI-Out-Filterresults: notjunk:1; V01:K0:DTBxg02qhJU=:fjTjwzWbOZx4GqFoy1ZDRh TcSizTf6KxusD2n1OEdarZoV9Y9iGO6BtToFLOdQLA4X8eD5G5+rAOLU4hGhdl8DIX+oTU/K+ ITeet1zLYV7IjSdo4TkL7DCPhWryNhnjaOZw2BcMSNJ/putXSrT9KVHL8MtNgKOgoa0J+eqnk 3KkLsXinjJRR8sfC2cJgBKPley6q9SNHBi2Gl9HMDRlCpyU0Exp11SeyjqOUZQDropSQEzHuv 9cMMDzwtKBlZQaT0TXm9hnrF3F5jU5VbZ23XAOF4uM6Z5aUOtoG4036JCPTPJ+Fmz18IzaczQ E1cYeT6qCsXRwH8nYLsaBbUGAkgQjhOAa26ZUIWgVYA68/XuImQT11Q+bQWOHILawMQF85Znt tTWhr0EhBF7rWi8U1VGaZ64/YYjv67PPRS0fWGIWu3Awgu4g43K6Kd+XOvQgagcw6aosEuQd4 1FPxJUxBNRoJVWUJLfihm9q1riMmhk+az/oAAuaLW5dD8JIEA2G7+SM9Zl5RX2hyKSRFusb5k vR+O4x0JbWkDxRD2PYdoggFch0mp0WuH0qzkxo7C7h5B5H6ubX+PN1W2YFQ1qrN+SraNgVQ5k LUX4aMZ8JYv6wtfVURvFRiaule7OG/Mupilz1JpBnnlus5JCxLiL7iDul+/vPMFX6S67JsFvw zZJTIwOa7dkodu3QTkaQE3CQvjABCGRIoAmQsQQB9KIYCF0KLsoIR3639Quyd+zAdVHAxPyKn SGZY3JhGyX5foZ6hzjMMuIUi5TTCYWUliMMxQQ== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org gcc-7 points out that a negative port_num value would overflow the string buffer: drivers/infiniband/hw/mlx4/sysfs.c: In function 'mlx4_ib_device_register_sysfs': drivers/infiniband/hw/mlx4/sysfs.c:251:16: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=] drivers/infiniband/hw/mlx4/sysfs.c:251:2: note: 'sprintf' output between 2 and 11 bytes into a destination of size 10 drivers/infiniband/hw/mlx4/sysfs.c:303:17: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=] drivers/infiniband/hw/mlx4/sysfs.c:303:3: note: 'sprintf' output between 2 and 11 bytes into a destination of size 10 While we should be able to assume that port_num is positive here, making the buffer one byte longer has no downsides and avoids the warning. Fixes: c1e7e466120b ("IB/mlx4: Add iov directory in sysfs under the ib device") Signed-off-by: Arnd Bergmann --- drivers/infiniband/hw/mlx4/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c index 0ba5ba7540c8..e219093d2764 100644 --- a/drivers/infiniband/hw/mlx4/sysfs.c +++ b/drivers/infiniband/hw/mlx4/sysfs.c @@ -221,7 +221,7 @@ void del_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num, static int add_port_entries(struct mlx4_ib_dev *device, int port_num) { int i; - char buff[10]; + char buff[11]; struct mlx4_ib_iov_port *port = NULL; int ret = 0 ; struct ib_port_attr attr;