Showing error 755

User: Jiri Slaby
Error type: Invalid Pointer Dereference
Error type description: A pointer which is invalid is being dereferenced
File location: kernel/module.c
Line in file: 505
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Smatch (1.59)
Entered: 2011-11-07 22:22:22 UTC


Source:

 475        if (i+1 < pcpu_num_used && pcpu_size[i+1] >= 0) {
 476                pcpu_size[i] += pcpu_size[i+1];
 477                pcpu_num_used--;
 478                memmove(&pcpu_size[i+1], &pcpu_size[i+2],
 479                        (pcpu_num_used - (i+1)) * sizeof(pcpu_size[0]));
 480        }
 481}
 482
 483static unsigned int find_pcpusec(Elf_Ehdr *hdr,
 484                                 Elf_Shdr *sechdrs,
 485                                 const char *secstrings)
 486{
 487        return find_sec(hdr, sechdrs, secstrings, ".data.percpu");
 488}
 489
 490static void percpu_modcopy(void *pcpudest, const void *from, unsigned long size)
 491{
 492        int cpu;
 493
 494        for_each_possible_cpu(cpu)
 495                memcpy(pcpudest + per_cpu_offset(cpu), from, size);
 496}
 497
 498static int percpu_modinit(void)
 499{
 500        pcpu_num_used = 2;
 501        pcpu_num_allocated = 2;
 502        pcpu_size = kmalloc(sizeof(pcpu_size[0]) * pcpu_num_allocated,
 503                            GFP_KERNEL);
 504        /* Static in-kernel percpu data (used). */
 505        pcpu_size[0] = -(__per_cpu_end-__per_cpu_start);
 506        /* Free room. */
 507        pcpu_size[1] = PERCPU_ENOUGH_ROOM + pcpu_size[0];
 508        if (pcpu_size[1] < 0) {
 509                printk(KERN_ERR "No per-cpu room for modules.\n");
 510                pcpu_num_used = 1;
 511        }
 512
 513        return 0;
 514}
 515__initcall(percpu_modinit);
Show full sources