myri10ge: correct uninitialized variable use
PATCH 1/1 myri10ge: correct uninitialized variable use
Compiling using GCC 16.2.1, for aarch64, I see this error:
In function '__const_memcpy_toio_aligned64',
inlined from '__iowrite64_copy' at arch/arm64/include/asm/io.h:260:3,
inlined from 'myri10ge_dummy_rdma' at drivers/net/ethernet/myricom/myri10ge/myri10ge.c:535:2:arch/arm64/include/asm/io.h:217:17: error: '*(const u64 *)(&buf[6])' is used uninitialized [-Werror=uninitialized]
217 | asm volatile("str %x0, [%8, #8 * 0]\n"
| ^~~drivers/net/ethernet/myricom/myri10ge/myri10ge.c: In function 'myri10ge_dummy_rdma':drivers/net/ethernet/myricom/myri10ge/myri10ge.c:511:16: note: '*(const u64 *)(&buf[6])' was declared here
511 | __be32 buf[16] __attribute__ ((__aligned__(8)));
| ^~~
The correction seems to be straight-forward to silence/correct the issue. The additional change to the simplified __aligned(8) macro is suggested by checkpatch.
--- drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/myricom/myri10ge/myri10ge.c +2 -2
@@ -508,7 +508,7 @@ static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp)static void myri10ge_dummy_rdma (struct myri10ge_priv *mgp,int enable) {char __iomem *submit; - __be32 buf[16] __attribute__ ((__aligned__(8))); +__be32 buf[16 ]__aligned(8) = {0 };u32 dma_low, dma_high;int i;
@@ -713,7 +713,7 @@ static int myri10ge_get_firmware_capabilities(struct myri10ge_priv *mgp)static int myri10ge_load_firmware (struct myri10ge_priv *mgp,int adopt) {char __iomem *submit; - __be32 buf[16] __attribute__ ((__aligned__(8))); +__be32 buf[16 ]__aligned(8) = {0 };u32 dma_low, dma_high, size;int status, i;
Signature · 1 line
2.52.0
Quoted 18 lines · Mark Nicholson
Compiling using GCC 16.2.1, for aarch64, I see this error:
In function '
__const_memcpy_toio_aligned64',
inlined from '__iowrite64_copy' atarch/arm64/include/asm/io.h:260:3,
inlined from 'myri10ge_dummy_rdma' atdrivers/net/ethernet/myricom/myri10ge/myri10ge.c:535:2:arch/arm64/include/asm/io.h:217:17: error: '*(const u64 *)(&buf[6])' is used uninitialized [-Werror=uninitialized]217 | asm volatile("str %x0, [%8, #8 * 0]\n" | ^~~
drivers/net/ethernet/myricom/myri10ge/myri10ge.c: In function 'myri10ge_dummy_rdma':drivers/net/ethernet/myricom/myri10ge/myri10ge.c:511:16: note: '*(const u64 *)(&buf[6])' was declared here
511 |__be32buf[16]__attribute__((__aligned__(8)));
| ^~~
Quoted 3 lines
The correction seems to be straight-forward to silence/correct the issue. The additional change to the simplified
__aligned(8)macro is suggested bycheckpatch.
The patch looks technically correct, but I would suggest improving it in two ways:
drivers/net/ethernet/myricom/myri10ge/myri10ge.c static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp) · line 513
Quoted 7 lines
static void
myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable){drivers/net/ethernet/myricom/myri10ge/myri10ge.c +1
-1char __iomem *submit; - __be32 buf[16] __attribute__ ((__aligned__(8))); +__be32 buf[16 ]__aligned(8) = {0 };u32 dma_low, dma_high;int i;
1. It is a bit confusing to initialize all 16 words once and then initialize half of them again a few lines down. For consistency, I would use one style consistently, either everything in the initialization, or everything individually as it is done today.
2. You only fix the bug in myri10ge_dummy_rdma() and myri10ge_load_firmware(), but the same problem exists in myri10ge_send_cmd() in the same file where the compiler missed it. Please check all of the driver to see if the same pattern exists elsewhere.
Arnd