trelay: use struct_size helper in allocation

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>
This commit is contained in:
Rosen Penev 2026-02-08 14:12:02 -08:00 committed by Robert Marko
parent 63e0c89038
commit 08d2c0514f

View 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;