Skip to content

Commit 8467d8b

Browse files
tobluxandreas-gaisler
authored andcommitted
sparc: Replace one-element array with flexible array member
Replace the deprecated one-element array with a modern flexible array member in the struct hvtramp_descr. Additionally, 15 unnecessary bytes were allocated for hdesc, but instead of fixing the parentheses in the open-coded version, use struct_size() to calculate the correct number of bytes. Link: KSPP#79 Signed-off-by: Thorsten Blum <[email protected]> Fixes: 6465874 ("[SPARC64]: Remove most limitations to kernel image size.") Reviewed-by: Andreas Larsson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andreas Larsson <[email protected]>
1 parent f6dee26 commit 8467d8b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

arch/sparc/include/asm/hvtramp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct hvtramp_descr {
1717
__u64 fault_info_va;
1818
__u64 fault_info_pa;
1919
__u64 thread_reg;
20-
struct hvtramp_mapping maps[1];
20+
struct hvtramp_mapping maps[];
2121
};
2222

2323
void hv_cpu_startup(unsigned long hvdescr_pa);

arch/sparc/kernel/smp_64.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,7 @@ static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg,
297297
unsigned long hv_err;
298298
int i;
299299

300-
hdesc = kzalloc(sizeof(*hdesc) +
301-
(sizeof(struct hvtramp_mapping) *
302-
num_kernel_image_mappings - 1),
300+
hdesc = kzalloc(struct_size(hdesc, maps, num_kernel_image_mappings),
303301
GFP_KERNEL);
304302
if (!hdesc) {
305303
printk(KERN_ERR "ldom_startcpu_cpuid: Cannot allocate "

0 commit comments

Comments
 (0)