From patchwork Fri Jul 5 11:26:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13724996 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75F7B149DE4 for ; Fri, 5 Jul 2024 11:27:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720178826; cv=none; b=RskEmeqLXKw8LbeQzd8dzuTRnURfdIgosmDSr9DznS42SXfVecQukFmDzJtHJ5c9ZK4qdyMNZfyUpjeIxtW5SoptpYoRMR3UFlKJBey30drEitvoAMu2GIqnSV3HzXIBCBl1w+DBONGxeh23HEQVQf93FgkWZ0gMnv4Uz/dcsOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720178826; c=relaxed/simple; bh=/iqhISmyjp10Y9gZXJqXSHFekdzGto3I0yZH76KXFPw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l18C7Fx3Tcj+1b5rFAfzJ/b+fHz6Iqoi0F/39eY3Lv4AA/86vUpEppNbnmypXjJfDZ3uucO5gZtPm99NpOosSw5PTR7iNsTXLATjt2DCiYs8qhVyfYBAvIPkTXR2RmszAFvi+6mWnRxknxNkkc3qGWYZY+iQNadMZ8NgD3N2gpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ITt+bPGu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ITt+bPGu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 213C5C32781; Fri, 5 Jul 2024 11:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720178826; bh=/iqhISmyjp10Y9gZXJqXSHFekdzGto3I0yZH76KXFPw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ITt+bPGujL39bzyL+8MC5J48OI+puhMSJeRgObQImIADNNaAu/StWrx2phhDEVAVb 9oHPEKuJxyQBo75mjMr81g1iyEcY3mn1bxr3Rk3YfBwowuhb8Uy3XiRIVYK589gbPl ZtYi8aKfNbsRu4Y6riGrO5OosUnM78QZx4AThfMc/C6urxTqhJLY9D/aiKGE77cJDD +X1ZPMC0efhjjfFjjqS8V+gb/UrSPLfQAN7zBiBQrYuFzcXSG71cbuQmOTFsJEe/ZA uOO4cBifihf+lZhk2twficp/zKlweaTrmHj/BRSG024WmQ9bP/gtXTPZrQ+RZKdnG+ hmLCz+3xnWFVg== From: Simon Horman Date: Fri, 05 Jul 2024 12:26:47 +0100 Subject: [PATCH net-next 1/3] bnxt_en: check for fw_ver_str truncation Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-bnxt-str-v1-1-bafc769ed89e@kernel.org> References: <20240705-bnxt-str-v1-0-bafc769ed89e@kernel.org> In-Reply-To: <20240705-bnxt-str-v1-0-bafc769ed89e@kernel.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Michael Chan , netdev@vger.kernel.org X-Mailer: b4 0.12.3 X-Patchwork-Delegate: kuba@kernel.org Given the sizes of the buffers involved, it is theoretically possible for fw_ver_str to be truncated. Detect this and stop ethtool initialisation if this occurs. Flagged by gcc-14: .../bnxt_ethtool.c: In function 'bnxt_ethtool_init': drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:4144:32: warning: '%s' directive output may be truncated writing up to 31 bytes into a region of size 26 [-Wformat-truncation=] 4144 | "/pkg %s", buf); | ^~ ~~~ In function 'bnxt_get_pkgver', inlined from 'bnxt_ethtool_init' at .../bnxt_ethtool.c:5056:3: .../bnxt_ethtool.c:4143:17: note: 'snprintf' output between 6 and 37 bytes into a destination of size 31 4143 | snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4144 | "/pkg %s", buf); | ~~~~~~~~~~~~~~~ Compile tested only. Signed-off-by: Simon Horman --- It appears to me that size is underestimated by 1 byte - it should be FW_VER_STR_LEN - offset rather than FW_VER_STR_LEN - offset - 1, because the size argument to snprintf should include the space for the trailing '\0'. But I have not changed that as it is separate from the issue this patch addresses. --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index bf157f6cc042..5ccc3cc4ba7d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4132,17 +4132,23 @@ int bnxt_get_pkginfo(struct net_device *dev, char *ver, int size) return rc; } -static void bnxt_get_pkgver(struct net_device *dev) +static int bnxt_get_pkgver(struct net_device *dev) { struct bnxt *bp = netdev_priv(dev); char buf[FW_VER_STR_LEN]; - int len; if (!bnxt_get_pkginfo(dev, buf, sizeof(buf))) { - len = strlen(bp->fw_ver_str); - snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len - 1, - "/pkg %s", buf); + int offset, size, rc; + + offset = strlen(bp->fw_ver_str); + size = FW_VER_STR_LEN - offset - 1; + + rc = snprintf(bp->fw_ver_str + offset, size, "/pkg %s", buf); + if (rc >= size) + return -E2BIG; } + + return 0; } static int bnxt_get_eeprom(struct net_device *dev, @@ -5052,8 +5058,11 @@ void bnxt_ethtool_init(struct bnxt *bp) struct net_device *dev = bp->dev; int i, rc; - if (!(bp->fw_cap & BNXT_FW_CAP_PKG_VER)) - bnxt_get_pkgver(dev); + if (!(bp->fw_cap & BNXT_FW_CAP_PKG_VER)) { + rc = bnxt_get_pkgver(dev); + if (rc) + return; + } bp->num_tests = 0; if (bp->hwrm_spec_code < 0x10704 || !BNXT_PF(bp)) From patchwork Fri Jul 5 11:26:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13724997 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 653CD149C70 for ; Fri, 5 Jul 2024 11:27:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720178828; cv=none; b=ECrwW592hoPeMUiIw9YGCkkfsVvx2/0MJw8D3w6E41uas1phGOHmo+UIrG3Vg9TGyKq44COnxr05Z0mXy+178v6tGE7TEhPhbVDiN3LLh1lKNF5I7kCeG+vfAvcMfZdlUScBBUjwDTEN1+1x4oTYeRZqt4A4St+vWiTvU8zt4ZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720178828; c=relaxed/simple; bh=yrBV5IftFpUXlj5MIMux76e/rLUFvmgMTRAmNwhBNoI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bfM5iNvwLb+OdAebzvLRX+BSzxrltlf1YQ0D2Ug6h0vmGmgTRnudNVaoLpvHnPt77AIk0Q6akS2CHz1NAc6wUPHK/H/mBTGUtlfq45Ykz/q5P93jTzh5Ksr06/4RUFywXGAeExuNXm4r7e4IXk1qUWuQz5jSjuIuLryka/QLd98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D7nE/x0T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D7nE/x0T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B19D0C32781; Fri, 5 Jul 2024 11:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720178827; bh=yrBV5IftFpUXlj5MIMux76e/rLUFvmgMTRAmNwhBNoI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=D7nE/x0T/C+QisBajqr9Irh+NeIxuAd18OzXZ1XEB95o0gViRPX5se1yXytKCkR/v nFVem7Sado/NIMcgRWCQ6jtSdVOGEstS3iPU6W5WAZyVyHZj44qdksEr0dY+KEtlJZ Wp57udGBEUtX7kFB7i5/AM28XRgschlpiaHTcGnjRTuQ/52W1zY6GfaP6XI0dCV5xI pxlF1nnZdvYk8DM+ezuYJ5weg3T2LU6NQauZ2NxAYTtkN1RGI/VtAYcOnHFOPRXIdF Z3YPAY62ZBk26CUeIkTQxbhAWK8NTltP8WzdY3TRaJd9grs8JhqujiwrheRQPppQDp lWLG9i9TMI7gQ== From: Simon Horman Date: Fri, 05 Jul 2024 12:26:48 +0100 Subject: [PATCH net-next 2/3] bnxt_en: check for irq name truncation Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-bnxt-str-v1-2-bafc769ed89e@kernel.org> References: <20240705-bnxt-str-v1-0-bafc769ed89e@kernel.org> In-Reply-To: <20240705-bnxt-str-v1-0-bafc769ed89e@kernel.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Michael Chan , netdev@vger.kernel.org X-Mailer: b4 0.12.3 X-Patchwork-Delegate: kuba@kernel.org Given the sizes of the buffers involved, it is theoretically possible for irq names to be truncated. Detect this and propagate an error if this occurs. Flagged by gcc-14: .../bnxt.c: In function 'bnxt_setup_int_mode': .../bnxt.c:10584:48: warning: '%s' directive output may be truncated writing 4 bytes into a region of size between 2 and 17 [-Wformat-truncation=] 10584 | snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", | ^~ ~~~~~~ In function 'bnxt_setup_inta', inlined from 'bnxt_setup_int_mode' at .../bnxt.c:10604:3: .../bnxt.c:10584:9: note: 'snprintf' output between 8 and 23 bytes into a destination of size 18 10584 | snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10585 | 0); | ~~ .../bnxt.c: In function 'bnxt_setup_int_mode': .../bnxt.c:10569:62: warning: '%s' directive output may be truncated writing between 2 and 4 bytes into a region of size between 2 and 17 [-Wformat-truncation=] 10569 | snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, | ^~ In function 'bnxt_setup_msix', inlined from 'bnxt_setup_int_mode' at .../bnxt.c:10602:3: .../bnxt.c:10569:58: note: directive argument in the range [-2147483643, 2147483646] 10569 | snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, | ^~~~~~~~~~ .../bnxt.c:10569:17: note: 'snprintf' output between 6 and 33 bytes into a destination of size 18 10569 | snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10570 | attr, i); | ~~~~~~~~ Compile tested only. Signed-off-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 220d05e2f6fa..15e68c8e599d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10538,7 +10538,7 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max, return __bnxt_trim_rings(bp, rx, tx, max, sh); } -static void bnxt_setup_msix(struct bnxt *bp) +static int bnxt_setup_msix(struct bnxt *bp) { const int len = sizeof(bp->irq_tbl[0].name); struct net_device *dev = bp->dev; @@ -10558,6 +10558,7 @@ static void bnxt_setup_msix(struct bnxt *bp) for (i = 0; i < bp->cp_nr_rings; i++) { int map_idx = bnxt_cp_num_to_irq_num(bp, i); char *attr; + int rc; if (bp->flags & BNXT_FLAG_SHARED_RINGS) attr = "TxRx"; @@ -10566,24 +10567,35 @@ static void bnxt_setup_msix(struct bnxt *bp) else attr = "tx"; - snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", dev->name, - attr, i); + rc = snprintf(bp->irq_tbl[map_idx].name, len, "%s-%s-%d", + dev->name, attr, i); + if (rc >= len) + return -E2BIG; bp->irq_tbl[map_idx].handler = bnxt_msix; } + + return 0; } -static void bnxt_setup_inta(struct bnxt *bp) +static int bnxt_setup_inta(struct bnxt *bp) { const int len = sizeof(bp->irq_tbl[0].name); + int rc; + if (bp->num_tc) { netdev_reset_tc(bp->dev); bp->num_tc = 0; } - snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", - 0); + rc = snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, + "TxRx", 0); + if (rc >= len) + return -E2BIG; + bp->irq_tbl[0].handler = bnxt_inta; + + return 0; } static int bnxt_init_int_mode(struct bnxt *bp); @@ -10599,9 +10611,11 @@ static int bnxt_setup_int_mode(struct bnxt *bp) } if (bp->flags & BNXT_FLAG_USING_MSIX) - bnxt_setup_msix(bp); + rc = bnxt_setup_msix(bp); else - bnxt_setup_inta(bp); + rc = bnxt_setup_inta(bp); + if (rc) + return rc; rc = bnxt_set_real_num_queues(bp); return rc; From patchwork Fri Jul 5 11:26:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13724998 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB3EC149C70 for ; Fri, 5 Jul 2024 11:27:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720178830; cv=none; b=W8vWr1G5nZb+1Hz3jD0dAWiz0jbrnUui2Z/Q8sccrUAX6lEgMXKgdBsp+9zzqXbo1404Fv5o86wnMmpgWqiP8ADP4JnR+Ry1G6tBU/N5/52EtGPHCOP0WHo3ZrlX6JE059SjJaPqjuVz0AU/PJHxrVGGN8z+RqTzNeD06EyotOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720178830; c=relaxed/simple; bh=6dJ7y7qGSnXLmbLAgtUrsUwlBeYudAdFnLWyh4KHBD0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ucN4drM93YDooshHz9jgUmHuj4IsmTLFRfp5Bejdi110WWl5RT37rHzpZ9EF0e0RLpW5mM0DHUuRRADBOp8LSl1rYctShMoP5sIi0bd0FvovXN5j/uyAb9IjcAeqxr/KWKLoi+MyXf/XYnevF2NEEfjmlZyTqZL/NtLLLM1Jq8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PM2OeBTR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PM2OeBTR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50A3FC116B1; Fri, 5 Jul 2024 11:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720178829; bh=6dJ7y7qGSnXLmbLAgtUrsUwlBeYudAdFnLWyh4KHBD0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PM2OeBTRf8DHeuKDWxCE3kZcgLXobrGygJYJdr6mWG6pYy5wEkI6ZGHOgUCg18w+j PDFvZ7ttsKeYgR8iX9sjpu8OZXJu/Nvc9vh735FZl7/YjbR3e9mKbsY2JNunYgJhRl OFF9DZH1PkvsXguhCWN01G50+qUkiCbM5pVw+0/QutGrIlgbGNZzmEo7k2UiwpLML4 1VU4qyPtgzdUYDfJ01j0NfjLl6cz21Zb1f1/AO3O309ZyR2VOj7nIutayWXLmZbabQ QOjbV/wjJdmcunzR8sckBtK+/UBblIOQeSZK9Zgm9nY2m8zpAsVXjh5g/rpH3iaJSm BxHHa5Es4JltQ== From: Simon Horman Date: Fri, 05 Jul 2024 12:26:49 +0100 Subject: [PATCH net-next 3/3] bnxt_en: avoid truncation of per rx run debugfs filename Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240705-bnxt-str-v1-3-bafc769ed89e@kernel.org> References: <20240705-bnxt-str-v1-0-bafc769ed89e@kernel.org> In-Reply-To: <20240705-bnxt-str-v1-0-bafc769ed89e@kernel.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Michael Chan , netdev@vger.kernel.org X-Mailer: b4 0.12.3 X-Patchwork-Delegate: kuba@kernel.org Although it seems unlikely in practice - there would need to be rx ring indexes greater than 10^10 - it is theoretically possible for the filename of per rx ring debugfs files to be truncated. This is because although a 16 byte buffer is provided, the length of the filename is restricted to 10 bytes. Remove this restriction and allow the entire buffer to be used. Also reduce the buffer to 12 bytes, which is sufficient. Given that the range of rx ring indexes likely much smaller than the maximum range of a 32-bit signed integer, a smaller buffer could be used, with some further changes. But this change seems simple, robust, and has minimal stack overhead. Flagged by gcc-14: .../bnxt_debugfs.c: In function 'bnxt_debug_dev_init': drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c:69:30: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 10 [-Wformat-truncation=] 69 | snprintf(qname, 10, "%d", ring_idx); | ^~ In function 'debugfs_dim_ring_init', inlined from 'bnxt_debug_dev_init' at .../bnxt_debugfs.c:87:4: .../bnxt_debugfs.c:69:29: note: directive argument in the range [-2147483643, 2147483646] 69 | snprintf(qname, 10, "%d", ring_idx); | ^~~~ .../bnxt_debugfs.c:69:9: note: 'snprintf' output between 2 and 12 bytes into a destination of size 10 69 | snprintf(qname, 10, "%d", ring_idx); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Compile tested only Signed-off-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c index 156c2404854f..127b7015f676 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c @@ -64,9 +64,9 @@ static const struct file_operations debugfs_dim_fops = { static void debugfs_dim_ring_init(struct dim *dim, int ring_idx, struct dentry *dd) { - static char qname[16]; + static char qname[12]; - snprintf(qname, 10, "%d", ring_idx); + snprintf(qname, sizeof(qname), "%d", ring_idx); debugfs_create_file(qname, 0600, dd, dim, &debugfs_dim_fops); }