]> www.infradead.org Git - users/hch/misc.git/commitdiff
hv_netvsc: Replace one-element array with flexible array member
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 16 Jan 2025 21:19:32 +0000 (22:19 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 18 Jan 2025 03:07:48 +0000 (19:07 -0800)
Replace the deprecated one-element array with a modern flexible array
member in the struct nvsp_1_message_send_receive_buffer_complete.

Use struct_size_t(,,1) instead of sizeof() to maintain the same size.

Compile-tested only.

Link: https://github.com/KSPP/linux/issues/79
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Tested-by: Roman Kisel <romank@linux.microsoft.com>
Reviewed-by: Roman Kisel <romank@linux.microsoft.com>
Link: https://patch.msgid.link/20250116211932.139564-2-thorsten.blum@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc.c

index e690b95b1bbb4c78914f25b4c2459289456031c1..234db693cefa4cf1995e2a186a278fdad8093e96 100644 (file)
@@ -464,7 +464,7 @@ struct nvsp_1_message_send_receive_buffer_complete {
         *  LargeOffset                            SmallOffset
         */
 
-       struct nvsp_1_receive_buffer_section sections[1];
+       struct nvsp_1_receive_buffer_section sections[];
 } __packed;
 
 /*
index 9afb08dbc350a3aaeb0813e27cffb7cd96323e64..d6f5b9ea3109d2bf0160015342d916c3393ea1c3 100644 (file)
@@ -866,7 +866,8 @@ static void netvsc_send_completion(struct net_device *ndev,
 
        case NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE:
                if (msglen < sizeof(struct nvsp_message_header) +
-                               sizeof(struct nvsp_1_message_send_receive_buffer_complete)) {
+                               struct_size_t(struct nvsp_1_message_send_receive_buffer_complete,
+                                             sections, 1)) {
                        netdev_err(ndev, "nvsp_msg1 length too small: %u\n",
                                   msglen);
                        return;