Back to success stories

Sample of Defect

Project Name CID Checker Category Developer Description
FreeBSD 1346853 UNINIT Uninitialized variables We were using the wrong "pages in" counter FreeBSD's ZFS port:could cause performance issues.Luckily this is not production code ... yet.
File: /sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
        if (ioflags & IO_APPEND)
                flags |= FAPPEND;
        if (ioflags & IO_NDELAY)
                flags |= FNONBLOCK;
        if (ioflags & IO_SYNC)
                flags |= (FSYNC | FDSYNC | FRSYNC);

        return (flags);
}

static int
zfs_getpages(struct vnode *vp, vm_page_t *m, int count, int *rbehind,
    int *rahead)
{
        znode_t *zp = VTOZ(vp);
        zfsvfs_t *zfsvfs = zp->z_zfsvfs;
        objset_t *os = zp->z_zfsvfs->z_os;
        vm_page_t mlast;
        vm_object_t object;
        caddr_t va;
        struct sf_buf *sf;
        off_t startoff, endoff;
        int i, error;
        vm_pindex_t reqstart, reqend;
 << 1. Declaring variable "reqsize" without initializer.
5776
5777
5778
5779
        int lsize, reqsize, size;

        object = m[0]->object;
        error = 0;
 < 2. Condition "zfsvfs->z_unmounted", taking false branch
5781
        ZFS_ENTER(zfsvfs);
 < 3. Condition "zp->z_sa_hdl == NULL", taking false branch
5782
5783
5784
        ZFS_VERIFY_ZP(zp);

        zfs_vmobject_wlock(object);
 < 4. Condition "m[count - 1]->valid != 0", taking true branch
 < 5. Condition "--count == 0", taking false branch
5785
5786
5787
5788
5789
5790
        if (m[count - 1]->valid != 0 && --count == 0) {
                zfs_vmobject_wunlock(object);
                goto out;
        }

        mlast = m[count - 1];
 < 6. Condition "((vm_ooffset_t)mlast->pindex << 12) >= object->un_pager.vnp.vnp_size", taking false branch
5792
5793
5794
5795
5796
5797
        if (IDX_TO_OFF(mlast->pindex) >=
            object->un_pager.vnp.vnp_size) {
                zfs_vmobject_wunlock(object);
                ZFS_EXIT(zfsvfs);
                return (zfs_vm_pagerret_bad);
        }
 < 7. Condition "0 /* sizeof (u_int) == 1 */", taking false branch
 < 8. Condition "0 /* sizeof (u_int) == 2 */", taking false branch
 < 9. Condition "1 /* sizeof (u_int) == 4 */", taking true branch
 < 10. Falling through to end of if statement
5799
        PCPU_INC(cnt.v_vnodein);
 <<< CID 1346853: Uninitialized variables UNINIT
 <<< 11. Using uninitialized value "reqsize".
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
        PCPU_ADD(cnt.v_vnodepgsin, reqsize);

        lsize = PAGE_SIZE;
        if (IDX_TO_OFF(mlast->pindex) + lsize > object->un_pager.vnp.vnp_size)
                lsize = object->un_pager.vnp.vnp_size -
                    IDX_TO_OFF(mlast->pindex);
        zfs_vmobject_wunlock(object);

        for (i = 0; i < count; i++) {
                size = PAGE_SIZE;
                if (i == count - 1)
                        size = lsize;
                va = zfs_map_page(m[i], &sf);
                error = dmu_read(os, zp->z_id, IDX_TO_OFF(m[i]->pindex),
                    size, va, DMU_READ_PREFETCH);
                if (size != PAGE_SIZE)
                        bzero(va + size, PAGE_SIZE - size);
                zfs_unmap_page(sf);
                if (error != 0)
                        goto out;
        }

        zfs_vmobject_wlock(object);
        for (i = 0; i < count; i++)
                m[i]->valid = VM_PAGE_BITS_ALL;
        zfs_vmobject_wunlock(object);
Events:
1. var_decl zfs_vnops.c:5776
11. uninit_use zfs_vnops.c:5800