Showing error 796

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


Source:

 509};
 510
 511int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
 512{
 513        ipmi_smi_t intf;
 514        LIST_HEAD(to_deliver);
 515        struct watcher_entry *e, *e2;
 516
 517        mutex_lock(&smi_watchers_mutex);
 518
 519        mutex_lock(&ipmi_interfaces_mutex);
 520
 521        /* Build a list of things to deliver. */
 522        list_for_each_entry(intf, &ipmi_interfaces, link) {
 523                if (intf->intf_num == -1)
 524                        continue;
 525                e = kmalloc(sizeof(*e), GFP_KERNEL);
 526                if (!e)
 527                        goto out_err;
 528                kref_get(&intf->refcount);
 529                e->intf = intf;
 530                e->intf_num = intf->intf_num;
 531                list_add_tail(&e->link, &to_deliver);
 532        }
 533
 534        /* We will succeed, so add it to the list. */
 535        list_add(&watcher->link, &smi_watchers);
 536
 537        mutex_unlock(&ipmi_interfaces_mutex);
 538
 539        list_for_each_entry_safe(e, e2, &to_deliver, link) {
 540                list_del(&e->link);
 541                watcher->new_smi(e->intf_num, e->intf->si_dev);
 542                kref_put(&e->intf->refcount, intf_free);
 543                kfree(e);
 544        }
 545
 546        mutex_unlock(&smi_watchers_mutex);
 547
 548        return 0;
 549
Show full sources