From patchwork Tue Feb 7 13:01:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9559949 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 6745F602B1 for ; Tue, 7 Feb 2017 13:10:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A1E828395 for ; Tue, 7 Feb 2017 13:10:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DD6828404; Tue, 7 Feb 2017 13:10:24 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 E388928395 for ; Tue, 7 Feb 2017 13:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754975AbdBGNBg (ORCPT ); Tue, 7 Feb 2017 08:01:36 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:36596 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754941AbdBGNBe (ORCPT ); Tue, 7 Feb 2017 08:01:34 -0500 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v17D1JuY032682 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Feb 2017 13:01:19 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v17D1Igx031417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Feb 2017 13:01:19 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v17D1Gj1026154; Tue, 7 Feb 2017 13:01:17 GMT Received: from mwanda (/154.0.138.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 07 Feb 2017 05:01:15 -0800 Date: Tue, 7 Feb 2017 16:01:04 +0300 From: Dan Carpenter To: QLogic-Storage-Upstream@cavium.com, Thomas Gleixner Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] scsi: qedi: silence sprintf() overflow warning Message-ID: <20170207130103.GA31552@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: userv0022.oracle.com [156.151.31.74] 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 The problem here is this: sprintf(host_buf, "qedi_ofld%d", qedi->shost->host_no); host_buf is 16 character so we only have 6 characters left for ->host_no. But ->host_no is set in scsi_host_alloc(): index = ida_simple_get(&host_index_ida, 0, 0, GFP_KERNEL); It could theoretically go up to 0x8000000 so we need space for 10 digits. Signed-off-by: Dan Carpenter diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 5eda21d903e9..0dcf3b08230c 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c @@ -1735,7 +1735,7 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) u32 dp_module = 0; u8 dp_level = 0; bool is_vf = false; - char host_buf[16]; + char host_buf[20]; struct qed_link_params link_params; struct qed_slowpath_params sp_params; struct qed_probe_params qed_params;