Skip to content

Commit c00f94a

Browse files
tititiou36bjorn-helgaas
authored andcommitted
x86/PCI: Use struct_size() in pirq_convert_irt_table()
Use struct_size() instead of hand-writing it. It is less verbose, more robust and more informative. Link: https://lore.kernel.org/r/00a5cc2cd322e7dea26579916ac6dda9c637aa57.1684518118.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 091f9f7 commit c00f94a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/pci/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ static inline struct irq_routing_table *pirq_convert_irt_table(u8 *addr,
136136
if (ir->signature != IRT_SIGNATURE || !ir->used || ir->size < ir->used)
137137
return NULL;
138138

139-
size = sizeof(*ir) + ir->used * sizeof(ir->slots[0]);
139+
size = struct_size(ir, slots, ir->used);
140140
if (size > limit - addr)
141141
return NULL;
142142

143143
DBG(KERN_DEBUG "PCI: $IRT Interrupt Routing Table found at 0x%lx\n",
144144
__pa(ir));
145145

146-
size = sizeof(*rt) + ir->used * sizeof(rt->slots[0]);
146+
size = struct_size(rt, slots, ir->used);
147147
rt = kzalloc(size, GFP_KERNEL);
148148
if (!rt)
149149
return NULL;

0 commit comments

Comments
 (0)