[dpdk-stable] patch 'net/hinic: fix repeating cable log and length check' has been queued to stable release 19.11.3

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue May 19 14:53:45 CEST 2020


Hi,

FYI, your patch has been queued to stable release 19.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/21/20. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Thanks.

Luca Boccassi

---
>From 32f349234b5ed4e818081c38d90eb88a2750e08f Mon Sep 17 00:00:00 2001
From: Kevin Traynor <ktraynor at redhat.com>
Date: Fri, 6 Mar 2020 12:06:52 +0000
Subject: [PATCH] net/hinic: fix repeating cable log and length check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[ upstream commit ece8e4c262f8091361e9b261c4e4c6257d2b8bda ]

gcc 10.0.1 reports:

../drivers/net/hinic/base/hinic_pmd_hwdev.c: In function ‘print_cable_info’:
../drivers/net/hinic/base/hinic_pmd_hwdev.c:1398:3:
warning:
‘snprintf’ argument 4 may overlap destination object ‘tmp_str’
[-Wrestrict]
 1398 |   snprintf(tmp_str + strlen(tmp_str), (sizeof(tmp_str) - 1),
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1399 |     "%s, Temperature: %u", tmp_str,
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1400 |     info->cable_temp);
      |     ~~~~~~~~~~~~~~~~~

The warning is that tmp_str is in both src and dest.

Anyway, the current code is incorrect and because of the +strlen
the existing string will be repeated twice and max length
does not limit to the end of the string.

Fix by removing tmp_str from the src of snprintf and adding the
correct max length.

Fixes: d9ce1917941c ("net/hinic/base: add hardware operation")

Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
 drivers/net/hinic/base/hinic_pmd_hwdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hinic/base/hinic_pmd_hwdev.c b/drivers/net/hinic/base/hinic_pmd_hwdev.c
index b6c821a2ad..fd0292f84c 100644
--- a/drivers/net/hinic/base/hinic_pmd_hwdev.c
+++ b/drivers/net/hinic/base/hinic_pmd_hwdev.c
@@ -1395,9 +1395,9 @@ static void print_cable_info(struct hinic_link_info *info)
 		 tmp_vendor, info->sfp_type ? "SFP" : "QSFP", port_type,
 		 info->cable_length, info->cable_max_speed);
 	if (info->port_type != LINK_PORT_COPPER)
-		snprintf(tmp_str + strlen(tmp_str), (sizeof(tmp_str) - 1),
-			 "%s, Temperature: %u", tmp_str,
-			 info->cable_temp);
+		snprintf(tmp_str + strlen(tmp_str),
+			 sizeof(tmp_str) - strlen(tmp_str),
+			 ", Temperature: %u", info->cable_temp);
 
 	PMD_DRV_LOG(INFO, "Cable information: %s", tmp_str);
 }
-- 
2.20.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2020-05-19 13:56:20.265836942 +0100
+++ 0035-net-hinic-fix-repeating-cable-log-and-length-check.patch	2020-05-19 13:56:18.227501963 +0100
@@ -1,4 +1,4 @@
-From ece8e4c262f8091361e9b261c4e4c6257d2b8bda Mon Sep 17 00:00:00 2001
+From 32f349234b5ed4e818081c38d90eb88a2750e08f Mon Sep 17 00:00:00 2001
 From: Kevin Traynor <ktraynor at redhat.com>
 Date: Fri, 6 Mar 2020 12:06:52 +0000
 Subject: [PATCH] net/hinic: fix repeating cable log and length check
@@ -6,6 +6,8 @@
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
 
+[ upstream commit ece8e4c262f8091361e9b261c4e4c6257d2b8bda ]
+
 gcc 10.0.1 reports:
 
 ../drivers/net/hinic/base/hinic_pmd_hwdev.c: In function ‘print_cable_info’:
@@ -30,7 +32,6 @@
 correct max length.
 
 Fixes: d9ce1917941c ("net/hinic/base: add hardware operation")
-Cc: stable at dpdk.org
 
 Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
 Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>


More information about the stable mailing list