* [PATCH] greybus: svc: use kzalloc_flex
@ 2026-03-17 3:14 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-03-17 3:14 UTC (permalink / raw)
To: linux-kernel
Cc: Johan Hovold, Alex Elder, Greg Kroah-Hartman,
moderated list:GREYBUS SUBSYSTEM
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>
---
drivers/greybus/svc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/greybus/svc.c b/drivers/greybus/svc.c
index 1b854f53f21e..490577731a19 100644
--- a/drivers/greybus/svc.c
+++ b/drivers/greybus/svc.c
@@ -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;
--
2.53.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-17 3:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-17 3:14 [PATCH] greybus: svc: use kzalloc_flex Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®