[PATCH 1/3] firewire: core: use kzalloc_flex() to allocate structure with quadlet array
From: Takashi Sakamoto
Date: Mon Sep 28 2026 - 09:20:47 EST
fw_core_handle_request() is now called in process context, so GFP_KERNEL
is available. The fw_request structure has a trailing flexible array
member of quadlets to store packet data. Use kzalloc_flex() to allocate
the structure together with storage for the flexible array member.
Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
drivers/firewire/core-transaction.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 7450eb0ac3cd..b4fccabb8fb2 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -894,8 +894,8 @@ static struct fw_request *allocate_request(struct fw_card *card,
return NULL;
}
- request = kmalloc(sizeof(*request) + length, GFP_ATOMIC);
- if (request == NULL)
+ request = kzalloc_flex(*request, data, DIV_ROUND_UP(length, sizeof(u32)));
+ if (!request)
return NULL;
kref_init(&request->kref);
--
2.53.0