]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
greybus: svc: use kzalloc_flex
authorRosen Penev <rosenp@gmail.com>
Tue, 17 Mar 2026 03:14:58 +0000 (20:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2026 13:55:01 +0000 (15:55 +0200)
Avoid manual sizeof math by using the proper helper.

Also use struct_size for the buffer size.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260317031458.93315-1-rosenp@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/greybus/svc.c

index 1b854f53f21e2207d44ab3b132622ab16eb7e898..490577731a190e096760523f1f8903670d29fd6f 100644 (file)
@@ -775,10 +775,9 @@ static void gb_svc_pwrmon_debugfs_init(struct gb_svc *svc)
        if (!rail_count || rail_count > GB_SVC_PWRMON_MAX_RAIL_COUNT)
                goto err_pwrmon_debugfs;
 
-       bufsize = sizeof(*rail_names) +
-               GB_SVC_PWRMON_RAIL_NAME_BUFSIZE * rail_count;
+       bufsize = struct_size(rail_names, name, rail_count);
 
-       rail_names = kzalloc(bufsize, GFP_KERNEL);
+       rail_names = kzalloc_flex(*rail_names, name, rail_count);
        if (!rail_names)
                goto err_pwrmon_debugfs;