* [PATCH 1/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data
@ 2017-03-23 14:55 Arnd Bergmann
2017-03-23 14:55 ` [PATCH 2/3] net: hns: fix uninitialized data use Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-03-23 14:55 UTC (permalink / raw)
To: Yisen Zhuang, Salil Mehta, David S. Miller
Cc: Arnd Bergmann, Daode Huang, Qianqian Xie, Kejian Yan,
Wei Yongjun, oulijun, netdev, linux-kernel
hns_dsaf_set_mac_key() calls dsaf_set_field() on an uninitialized field,
which will then change only a few of its bits, causing a warning with
the latest gcc:
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_uc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
(origin) &= (~(mask)); \
^~
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_mac_mc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_add_mac_mc_port':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_rm_mac_addr':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_del_mac_mc_port':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_uc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_get_mac_mc_entry':
hisilicon/hns/hns_dsaf_reg.h:1046:12: error: 'mac_key.low.bits.port_vlan' may be used uninitialized in this function [-Werror=maybe-uninitialized]
The code is actually correct since we always set all 16 bits of the
port_vlan field, but gcc correctly points out that the first
access does contain uninitialized data.
This initializes the field to zero first before setting the
individual bits.
Fixes: 5483bfcb169c ("net: hns: modify tcam table and set mac key")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 90dbda792614..1ec6d4bb6044 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -1519,6 +1519,7 @@ static void hns_dsaf_set_mac_key(
mac_key->high.bits.mac_3 = addr[3];
mac_key->low.bits.mac_4 = addr[4];
mac_key->low.bits.mac_5 = addr[5];
+ mac_key->low.bits.port_vlan = 0;
dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_VLAN_M,
DSAF_TBL_TCAM_KEY_VLAN_S, vlan_id);
dsaf_set_field(mac_key->low.bits.port_vlan, DSAF_TBL_TCAM_KEY_PORT_M,
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] net: hns: fix uninitialized data use
2017-03-23 14:55 [PATCH 1/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
@ 2017-03-23 14:55 ` Arnd Bergmann
2017-03-23 14:55 ` [PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
2017-03-23 18:54 ` [PATCH 1/3] net: " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-03-23 14:55 UTC (permalink / raw)
To: Yisen Zhuang, Salil Mehta, David S. Miller
Cc: Arnd Bergmann, Daode Huang, Qianqian Xie, Kejian Yan, oulijun,
Wei Yongjun, netdev, linux-kernel
When dev_dbg() is enabled, we print uninitialized data, as gcc-7.0.1
now points out:
ethernet/hisilicon/hns/hns_dsaf_main.c: In function 'hns_dsaf_set_promisc_tcam':
ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.low.val' may be used uninitialized in this function [-Werror=maybe-uninitialized]
ethernet/hisilicon/hns/hns_dsaf_main.c:2947:75: error: 'tbl_tcam_data.high.val' may be used uninitialized in this function [-Werror=maybe-uninitialized]
We also pass the data into hns_dsaf_tcam_mc_cfg(), which might later
use it (not sure about that), so it seems safer to just always initialize
the tbl_tcam_data structure.
Fixes: 1f5fa2dd1cfa ("net: hns: fix for promisc mode in HNS driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1ec6d4bb6044..403ea9db6dbd 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -2925,10 +2925,11 @@ void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev,
/* find the tcam entry index for promisc */
entry_index = dsaf_promisc_tcam_entry(port);
+ memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data));
+ memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask));
+
/* config key mask */
if (enable) {
- memset(&tbl_tcam_data, 0, sizeof(tbl_tcam_data));
- memset(&tbl_tcam_mask, 0, sizeof(tbl_tcam_mask));
dsaf_set_field(tbl_tcam_data.low.bits.port_vlan,
DSAF_TBL_TCAM_KEY_PORT_M,
DSAF_TBL_TCAM_KEY_PORT_S, port);
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data
2017-03-23 14:55 [PATCH 1/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
2017-03-23 14:55 ` [PATCH 2/3] net: hns: fix uninitialized data use Arnd Bergmann
@ 2017-03-23 14:55 ` Arnd Bergmann
2017-03-23 18:54 ` [PATCH 1/3] net: " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-03-23 14:55 UTC (permalink / raw)
To: Lijun Ou, Wei Hu(Xavier), Doug Ledford, Sean Hefty, Hal Rosenstock
Cc: Arnd Bergmann, Salil, Dongdong Huang(Donald),
Shaobo Xu, Stephen Boyd, linux-rdma, linux-kernel
hns_roce_v1_cq_set_ci() calls roce_set_bit() on an uninitialized field,
which will then change only a few of its bits, causing a warning with
the latest gcc:
infiniband/hw/hns/hns_roce_hw_v1.c: In function 'hns_roce_v1_cq_set_ci':
infiniband/hw/hns/hns_roce_hw_v1.c:1854:23: error: 'doorbell[1]' is used uninitialized in this function [-Werror=uninitialized]
roce_set_bit(doorbell[1], ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_HW_SYNS_S, 1);
The code is actually correct since we always set all bits of the
port_vlan field, but gcc correctly points out that the first
access does contain uninitialized data.
This initializes the field to zero first before setting the
individual bits.
Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index ec68f56e8ee5..882073a6ec77 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -1851,6 +1851,7 @@ void hns_roce_v1_cq_set_ci(struct hns_roce_cq *hr_cq, u32 cons_index)
u32 doorbell[2];
doorbell[0] = cons_index & ((hr_cq->cq_depth << 1) - 1);
+ doorbell[1] = 0;
roce_set_bit(doorbell[1], ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_HW_SYNS_S, 1);
roce_set_field(doorbell[1], ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_CMD_M,
ROCEE_DB_OTHERS_H_ROCEE_DB_OTH_CMD_S, 3);
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data
2017-03-23 14:55 [PATCH 1/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
2017-03-23 14:55 ` [PATCH 2/3] net: hns: fix uninitialized data use Arnd Bergmann
2017-03-23 14:55 ` [PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
@ 2017-03-23 18:54 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-03-23 18:54 UTC (permalink / raw)
To: arnd
Cc: yisen.zhuang, salil.mehta, huangdaode, xieqianqian, yankejian,
weiyongjun1, oulijun, netdev, linux-kernel
Arnd, I only see 2 patches out of 3 and no series header posting.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-23 18:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-23 14:55 [PATCH 1/3] net: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
2017-03-23 14:55 ` [PATCH 2/3] net: hns: fix uninitialized data use Arnd Bergmann
2017-03-23 14:55 ` [PATCH 3/3] infiniband: hns: avoid gcc-7.0.1 warning for uninitialized data Arnd Bergmann
2017-03-23 18:54 ` [PATCH 1/3] net: " David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).