binfmt: Use struct_size()
[linux-2.6-microblaze.git] / fs / binfmt_elf_fdpic.c
index d76ad3d..237ce38 100644 (file)
@@ -748,7 +748,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
        struct elf32_phdr *phdr;
        unsigned long load_addr, stop;
        unsigned nloads, tmp;
-       size_t size;
        int loop, ret;
 
        /* allocate a load map table */
@@ -760,8 +759,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
        if (nloads == 0)
                return -ELIBBAD;
 
-       size = sizeof(*loadmap) + nloads * sizeof(*seg);
-       loadmap = kzalloc(size, GFP_KERNEL);
+       loadmap = kzalloc(struct_size(loadmap, segs, nloads), GFP_KERNEL);
        if (!loadmap)
                return -ENOMEM;