]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
trelay: use struct_size helper in allocation 21960/head
authorRosen Penev <rosenp@gmail.com>
Sun, 8 Feb 2026 22:12:02 +0000 (14:12 -0800)
committerRobert Marko <robimarko@gmail.com>
Fri, 13 Mar 2026 18:58:05 +0000 (19:58 +0100)
Makes it clear that the allocation is dealing with a flex array member.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21960
Signed-off-by: Robert Marko <robimarko@gmail.com>
package/kernel/trelay/src/trelay.c

index 8b3bef2a8eb6ce3081b5d1a3946aab18cdcb8717..32ac623afe1f917741f741543e38a4974dcebdbd 100644 (file)
@@ -152,7 +152,7 @@ static int trelay_do_add(char *name, char *devn1, char *devn2)
        struct trelay *tr, *tr1;
        int ret;
 
-       tr = kzalloc(sizeof(*tr) + strlen(name) + 1, GFP_KERNEL);
+       tr = kzalloc(struct_size(tr, name, strlen(name) + 1), GFP_KERNEL);
        if (!tr)
                return -ENOMEM;