Showing error 1784

User: Jiri Slaby
Error type: Invalid Pointer Dereference
Error type description: A pointer which is invalid is being dereferenced
File location: block/genhd.c
Line in file: 934
Project: Linux Kernel
Project version: 2.6.28
Tools: Smatch (1.59)
Entered: 2013-09-11 08:47:26 UTC


Source:

 904 * Matching bd_mutex locked, might sleep.
 905 *
 906 * RETURNS:
 907 * 0 on success, -errno on failure.
 908 */
 909int disk_expand_part_tbl(struct gendisk *disk, int partno)
 910{
 911        struct disk_part_tbl *old_ptbl = disk->part_tbl;
 912        struct disk_part_tbl *new_ptbl;
 913        int len = old_ptbl ? old_ptbl->len : 0;
 914        int target = partno + 1;
 915        size_t size;
 916        int i;
 917
 918        /* disk_max_parts() is zero during initialization, ignore if so */
 919        if (disk_max_parts(disk) && target > disk_max_parts(disk))
 920                return -EINVAL;
 921
 922        if (target <= len)
 923                return 0;
 924
 925        size = sizeof(*new_ptbl) + target * sizeof(new_ptbl->part[0]);
 926        new_ptbl = kzalloc_node(size, GFP_KERNEL, disk->node_id);
 927        if (!new_ptbl)
 928                return -ENOMEM;
 929
 930        INIT_RCU_HEAD(&new_ptbl->rcu_head);
 931        new_ptbl->len = target;
 932
 933        for (i = 0; i < len; i++)
 934                rcu_assign_pointer(new_ptbl->part[i], old_ptbl->part[i]);
 935
 936        disk_replace_part_tbl(disk, new_ptbl);
 937        return 0;
 938}
 939
 940static void disk_release(struct device *dev)
 941{
 942        struct gendisk *disk = dev_to_disk(dev);
 943
 944        kfree(disk->random);
Show full sources