mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
firewire: cdev: use kzalloc_flex() to allocate structure with quadlet array
Some event structures have a trailing flexible array member of quadlets to store event-specific data. Use kzalloc_flex() to allocate the structure together with storage for the flexible array member. Link: https://lore.kernel.org/r/20260928125718.50974-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
This commit is contained in:
parent
8fa3077dff
commit
b1790574d3
|
|
@ -683,8 +683,8 @@ static int init_request(struct client *client,
|
|||
request->length < 4)
|
||||
return -EINVAL;
|
||||
|
||||
e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL);
|
||||
if (e == NULL)
|
||||
e = kzalloc_flex(*e, rsp.with_tstamp.data, DIV_ROUND_UP(request->length, sizeof(u32)));
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
e->client = client;
|
||||
|
||||
|
|
@ -1696,7 +1696,7 @@ static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)
|
|||
if (!client->device->is_local)
|
||||
return -ENOSYS;
|
||||
|
||||
e = kzalloc(sizeof(*e) + sizeof(a->data), GFP_KERNEL);
|
||||
e = kzalloc_flex(*e, phy_packet.with_tstamp.data, ARRAY_SIZE(a->data));
|
||||
if (e == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -1762,7 +1762,8 @@ void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p)
|
|||
if (client->device->card != card)
|
||||
continue;
|
||||
|
||||
struct inbound_phy_packet_event *e = kmalloc(sizeof(*e) + 8, GFP_KERNEL);
|
||||
struct inbound_phy_packet_event *e =
|
||||
kzalloc_flex(*e, phy_packet.with_tstamp.data, 2);
|
||||
if (!e)
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user