Showing error 792

User: Jiri Slaby
Error type: Memory Leak
Error type description: There the code omits to free some allocated memory
File location: arch/x86/mm/kmmio.c
Line in file: 462
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:26:27 UTC


Source:

432/*
433 * Remove a kmmio probe. You have to synchronize_rcu() before you can be
434 * sure that the callbacks will not be called anymore. Only after that
435 * you may actually release your struct kmmio_probe.
436 *
437 * Unregistering a kmmio fault page has three steps:
438 * 1. release_kmmio_fault_page()
439 *    Disarm the page, wait a grace period to let all faults finish.
440 * 2. remove_kmmio_fault_pages()
441 *    Remove the pages from kmmio_page_table.
442 * 3. rcu_free_kmmio_fault_pages()
443 *    Actally free the kmmio_fault_page structs as with RCU.
444 */
445void unregister_kmmio_probe(struct kmmio_probe *p)
446{
447        unsigned long flags;
448        unsigned long size = 0;
449        const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK);
450        struct kmmio_fault_page *release_list = NULL;
451        struct kmmio_delayed_release *drelease;
452
453        spin_lock_irqsave(&kmmio_lock, flags);
454        while (size < size_lim) {
455                release_kmmio_fault_page(p->addr + size, &release_list);
456                size += PAGE_SIZE;
457        }
458        list_del_rcu(&p->list);
459        kmmio_count--;
460        spin_unlock_irqrestore(&kmmio_lock, flags);
461
462        drelease = kmalloc(sizeof(*drelease), GFP_ATOMIC);
463        if (!drelease) {
464                pr_crit("kmmio: leaking kmmio_fault_page objects.\n");
465                return;
466        }
467        drelease->release_list = release_list;
468
469        /*
470         * This is not really RCU here. We have just disarmed a set of
471         * pages so that they cannot trigger page faults anymore. However,
472         * we cannot remove the pages from kmmio_page_table,
Show full sources