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: 9840825 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 94613602BD for ; Fri, 14 Jul 2017 12:15:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 871C328752 for ; Fri, 14 Jul 2017 12:15:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B8C228778; Fri, 14 Jul 2017 12:15:15 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 241D828752 for ; Fri, 14 Jul 2017 12:15:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932299AbdGNMPK (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Leon Romanovsky --- drivers/infiniband/hw/mlx4/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;