Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

myri10ge: avoid uninitialized variable use

While compile testing on less common architectures, I noticed that gcc-10 on
s390 finds a bug that all other configurations seem to miss:

drivers/net/ethernet/myricom/myri10ge/myri10ge.c: In function 'myri10ge_set_multicast_list':
drivers/net/ethernet/myricom/myri10ge/myri10ge.c:391:25: error: 'cmd.data0' is used uninitialized in this function [-Werror=uninitialized]
391 | buf->data0 = htonl(data->data0);
| ^~
drivers/net/ethernet/myricom/myri10ge/myri10ge.c:392:25: error: '*((void *)&cmd+4)' is used uninitialized in this function [-Werror=uninitialized]
392 | buf->data1 = htonl(data->data1);
| ^~
drivers/net/ethernet/myricom/myri10ge/myri10ge.c: In function 'myri10ge_allocate_rings':
drivers/net/ethernet/myricom/myri10ge/myri10ge.c:392:13: error: 'cmd.data1' is used uninitialized in this function [-Werror=uninitialized]
392 | buf->data1 = htonl(data->data1);
drivers/net/ethernet/myricom/myri10ge/myri10ge.c:1939:22: note: 'cmd.data1' was declared here
1939 | struct myri10ge_cmd cmd;
| ^~~
drivers/net/ethernet/myricom/myri10ge/myri10ge.c:393:13: error: 'cmd.data2' is used uninitialized in this function [-Werror=uninitialized]
393 | buf->data2 = htonl(data->data2);
drivers/net/ethernet/myricom/myri10ge/myri10ge.c:1939:22: note: 'cmd.data2' was declared here
1939 | struct myri10ge_cmd cmd;

It would be nice to understand how to make other compilers catch this as
well, but for the moment I'll just shut up the warning by fixing the
undefined behavior in this driver.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20260205162935.2126442-1-arnd@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Arnd Bergmann and committed by
Jakub Kicinski
fd241734 2d593cf1

+27 -1
+27 -1
drivers/net/ethernet/myricom/myri10ge/myri10ge.c
··· 688 688 689 689 /* probe for IPv6 TSO support */ 690 690 mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO; 691 + cmd.data0 = 0, 692 + cmd.data1 = 0, 693 + cmd.data2 = 0, 691 694 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, 692 695 &cmd, 0); 693 696 if (status == 0) { ··· 809 806 | (addr[2] << 8) | addr[3]); 810 807 811 808 cmd.data1 = ((addr[4] << 8) | (addr[5])); 809 + cmd.data2 = 0; 812 810 813 811 status = myri10ge_send_cmd(mgp, MXGEFW_SET_MAC_ADDRESS, &cmd, 0); 814 812 return status; ··· 821 817 int status, ctl; 822 818 823 819 ctl = pause ? MXGEFW_ENABLE_FLOW_CONTROL : MXGEFW_DISABLE_FLOW_CONTROL; 820 + cmd.data0 = 0, 821 + cmd.data1 = 0, 822 + cmd.data2 = 0, 824 823 status = myri10ge_send_cmd(mgp, ctl, &cmd, 0); 825 824 826 825 if (status) { ··· 841 834 int status, ctl; 842 835 843 836 ctl = promisc ? MXGEFW_ENABLE_PROMISC : MXGEFW_DISABLE_PROMISC; 837 + cmd.data0 = 0; 838 + cmd.data1 = 0; 839 + cmd.data2 = 0; 844 840 status = myri10ge_send_cmd(mgp, ctl, &cmd, atomic); 845 841 if (status) 846 842 netdev_err(mgp->dev, "Failed to set promisc mode\n"); ··· 1956 1946 /* get ring sizes */ 1957 1947 slice = ss - mgp->ss; 1958 1948 cmd.data0 = slice; 1949 + cmd.data1 = 0; 1950 + cmd.data2 = 0; 1959 1951 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0); 1960 1952 tx_ring_size = cmd.data0; 1961 1953 cmd.data0 = slice; ··· 2250 2238 status = 0; 2251 2239 if (slice == 0 || (mgp->dev->real_num_tx_queues > 1)) { 2252 2240 cmd.data0 = slice; 2241 + cmd.data1 = 0; 2242 + cmd.data2 = 0; 2253 2243 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, 2254 2244 &cmd, 0); 2255 2245 ss->tx.lanai = (struct mcp_kreq_ether_send __iomem *) 2256 2246 (mgp->sram + cmd.data0); 2257 2247 } 2258 2248 cmd.data0 = slice; 2249 + cmd.data1 = 0; 2250 + cmd.data2 = 0; 2259 2251 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, 2260 2252 &cmd, 0); 2261 2253 ss->rx_small.lanai = (struct mcp_kreq_ether_recv __iomem *) ··· 2328 2312 if (mgp->num_slices > 1) { 2329 2313 cmd.data0 = mgp->num_slices; 2330 2314 cmd.data1 = MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE; 2315 + cmd.data2 = 0; 2331 2316 if (mgp->dev->real_num_tx_queues > 1) 2332 2317 cmd.data1 |= MXGEFW_SLICE_ENABLE_MULTIPLE_TX_QUEUES; 2333 2318 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ENABLE_RSS_QUEUES, ··· 2431 2414 2432 2415 /* now give firmware buffers sizes, and MTU */ 2433 2416 cmd.data0 = dev->mtu + ETH_HLEN + VLAN_HLEN; 2417 + cmd.data1 = 0; 2418 + cmd.data2 = 0; 2434 2419 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_MTU, &cmd, 0); 2435 2420 cmd.data0 = mgp->small_bytes; 2436 2421 status |= ··· 2491 2472 static int myri10ge_close(struct net_device *dev) 2492 2473 { 2493 2474 struct myri10ge_priv *mgp = netdev_priv(dev); 2494 - struct myri10ge_cmd cmd; 2495 2475 int status, old_down_cnt; 2496 2476 int i; 2497 2477 ··· 2509 2491 2510 2492 netif_tx_stop_all_queues(dev); 2511 2493 if (mgp->rebooted == 0) { 2494 + struct myri10ge_cmd cmd; 2495 + 2512 2496 old_down_cnt = mgp->down_cnt; 2513 2497 mb(); 2498 + cmd.data0 = 0; 2499 + cmd.data1 = 0; 2500 + cmd.data2 = 0; 2514 2501 status = 2515 2502 myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_DOWN, &cmd, 0); 2516 2503 if (status) ··· 2979 2956 2980 2957 /* Disable multicast filtering */ 2981 2958 2959 + cmd.data0 = 0; 2960 + cmd.data1 = 0; 2961 + cmd.data2 = 0; 2982 2962 err = myri10ge_send_cmd(mgp, MXGEFW_ENABLE_ALLMULTI, &cmd, 1); 2983 2963 if (err != 0) { 2984 2964 netdev_err(dev, "Failed MXGEFW_ENABLE_ALLMULTI, error status: %d\n",