From patchwork Fri Jul 14 12:07:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 107787 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp889999obm; Fri, 14 Jul 2017 05:11:18 -0700 (PDT) X-Received: by 10.84.217.204 with SMTP id d12mr16204843plj.208.1500034278445; Fri, 14 Jul 2017 05:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500034278; cv=none; d=google.com; s=arc-20160816; b=lDS94HWMKB/VNL8BQdXd57MBL9PIXywdkzbEvxPdmgFap+ShgWkw6vrSgmgx4tBQdb uXvEVHzzCkfIcMogq5TKLOMHANPFVDvGZKn/gGpFGxjXBAYMXTFzwnKsUQIfA6iChazu DcpoVl6Tu9i1e/f7uiNSMnCd9KzKKII7XGJZI9pBcI2INEDEyH6BoGbBIponLXiknYrr brxn4GA/yJstHlQFhSX3cFMU71cJF7X8Zaf+FcMkWWbQjqOzsopGxtLVz0br28Dkq2nK Zms0/6bKRYULSgPXBh1CN1V9ySGZzAI2FvWoqP7cnA2jezISlw9v5l6V3bsdil1pwJes BFFA== 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=+eLLZjQTtghc2sbBTjA6ie1j7zCTVGKOuXgHcM77YW8=; b=LftVGPhEopXQ9RnYSxt/V9Gsn44MYQ1haxYri/mic4WhBVLCyL6rXNUk+XWmzjzlOK 9mqVei5KBBdWP3AOub48GTf6BoikaGKBozuxDrX18TWGTHl67lvF+EG7zs9MyHLD5SAj fy2D5NqqBYnVmZqBvoCVI2fvJDaj6K6Rm09JkNbo7QMdMxwDZCfzwUf+ELl5HNU/7QD3 bySuV9CfS8aohbbpTMcRZS5ZPtE4FMCv5g1ZMd7Ler9VNMhkdh+Rc2Nx3lVJPxT8F3CG Vu3myJ08xEGQmDgsvqgEdad0HavT1mGYLgf4c4ZgTff7TuBlkPXALCduYT+8h/Ic0ZL/ 43NQ== 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 n19si6404893pfb.298.2017.07.14.05.11.18; Fri, 14 Jul 2017 05:11:18 -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 S1754177AbdGNMLF (ORCPT + 6 others); Fri, 14 Jul 2017 08:11:05 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:50878 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753787AbdGNMLC (ORCPT ); Fri, 14 Jul 2017 08:11:02 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MKILu-1dXdZi0kgY-001lPF; Fri, 14 Jul 2017 14:09:48 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, "David S. Miller" , Philippe Reynes , Arnd Bergmann Cc: Greg Kroah-Hartman , Linus Torvalds , Guenter Roeck , akpm@linux-foundation.org, netdev@vger.kernel.org, "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, x86@kernel.org, Eric Dumazet , stephen hemminger , Jarod Wilson Subject: [PATCH 09/22] net: niu: fix format string overflow warning: Date: Fri, 14 Jul 2017 14:07:01 +0200 Message-Id: <20170714120720.906842-10-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:o9DsCjMqhYPrSeaoG05YBsMDCy0Xl0FwinimcpuSeTEqWhwFEbR wy9XTgaDd2Xa7ks6XmURLR10oGK+eTKv6Z+A/WT7mGlabQmqZN0XBotAbqzfV4qFOZlIaig LcbdKVjjWsNTI7Ibv5ui0RX0HMWeRw6Maa+BmM0oDK9FpNYtEb2Uv1ZadJsR0uLRmL4qhq3 ZQShAPcStXaYNdjP/27Sw== X-UI-Out-Filterresults: notjunk:1; V01:K0:PwoUYWXciTY=:6Vh/sLq2a9c67bQvlnw2cI IVTOl1SDgIvBXDEU7b/gm9Vn/v4mDYJqIm6Nbs67nWwz3GMZ+PAJ32DlK1N9dTzj4gZrtfLXZ F7+AFiom2tdDlFyCNDV5DrK+BMpevI+mj+fdvEsQi/vLeVu+V2ldpSxMWZNHtueDTgfz8IagG W2xk4mP/ntP1u2ttBVIJN9Sy6IeZh5312lKXFULryMw8sp42yz+ptgwwVW4zHE+V0AptRAgfF wfhJtc3y5cyUq2IgWXRwQZkQEjWu25kzD3cuHpJN7JOmXYod1lfrIKyiV/PRCGcA2zsvOcSI+ Zau3nSN3Gw8pjXJvsC71lxenJNHjjVGWHKOjzP+S53aZ2obnbutK+Ud/6qvb7c+CbP6C7tT/+ ehG4v+poR+xMEMnWlA2UsHrg+MKwSZ7ZXhy+u0MOzcYUverUx0YTN0hVvN1nDAN0rKuK01hln zwRdT9Zpj5PSk1iBFwkxedciziXyFpyN3asEHiBdJrN2tJJhpWe+Cyt476wL0l1znOdY/h/Vs cH3JS9qIqnMmuKi3aDHlduVClDk2kAeeK15bY5L0yDYqd+IFYBeFMQscyA4nZc58uZcDCeLg0 B6flwpmq6DImYbS8SIYMddVhfH9sbrvbMhwEGOy9Y8fcq5gzR2sVRCOkYWaeqUzsIJnOGDwnX v1pHqgtwx5B5wYDVhA4l7c66oJLkAKLrAnE3J38ck9mC8tAJ8wVZQHchmXy8W3/UQghRLs2u6 qdoUQzXHHWWbPDQN2HyWnf4sQ7PvnXGD2WeDqA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We get a warning for the port_name string that might be longer than six characters if we had more than 10 ports: drivers/net/ethernet/sun/niu.c: In function 'niu_put_parent': drivers/net/ethernet/sun/niu.c:9563:21: error: '%d' directive writing between 1 and 3 bytes into a region of size 2 [-Werror=format-overflow=] sprintf(port_name, "port%d", port); ^~~~~~~~ drivers/net/ethernet/sun/niu.c:9563:21: note: directive argument in the range [0, 255] drivers/net/ethernet/sun/niu.c:9563:2: note: 'sprintf' output between 6 and 8 bytes into a destination of size 6 sprintf(port_name, "port%d", port); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/ethernet/sun/niu.c: In function 'niu_pci_init_one': drivers/net/ethernet/sun/niu.c:9538:22: error: '%d' directive writing between 1 and 3 bytes into a region of size 2 [-Werror=format-overflow=] sprintf(port_name, "port%d", port); ^~~~~~~~ drivers/net/ethernet/sun/niu.c:9538:22: note: directive argument in the range [0, 255] drivers/net/ethernet/sun/niu.c:9538:3: note: 'sprintf' output between 6 and 8 bytes into a destination of size 6 While we know that the port number is small, there is no harm in making the format string two bytes longer to avoid the warning. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/sun/niu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index 46cb7f8955a2..4bb04aaf9650 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -9532,7 +9532,7 @@ static struct niu_parent *niu_get_parent(struct niu *np, p = niu_new_parent(np, id, ptype); if (p) { - char port_name[6]; + char port_name[8]; int err; sprintf(port_name, "port%d", port); @@ -9553,7 +9553,7 @@ static void niu_put_parent(struct niu *np) { struct niu_parent *p = np->parent; u8 port = np->port; - char port_name[6]; + char port_name[8]; BUG_ON(!p || p->ports[port] != np);