From 32dec7bd1a0bce6039a65768ed8552164a0130bf Mon Sep 17 00:00:00 2001 From: luozhengzheng Date: Fri, 11 Nov 2016 00:50:32 +0800 Subject: [PATCH] Fix coverity defects: CID 147503 CID 147503: Dereference after null check (FORWARD_NULL) Reviewed-by: Brian Behlendorf Signed-off-by: luozhengzheng Closes #5326 --- module/zfs/zfs_vnops.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 4a0f20166..7601e7618 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -1313,6 +1313,9 @@ zfs_create(struct inode *dip, char *name, vattr_t *vap, int excl, (vsecp || IS_EPHEMERAL(uid) || IS_EPHEMERAL(gid))) return (SET_ERROR(EINVAL)); + if (name == NULL) + return (SET_ERROR(EINVAL)); + ZFS_ENTER(zsb); ZFS_VERIFY_ZP(dzp); os = zsb->z_os; @@ -1667,6 +1670,9 @@ zfs_remove(struct inode *dip, char *name, cred_t *cr, int flags) int zflg = ZEXISTS; boolean_t waited = B_FALSE; + if (name == NULL) + return (SET_ERROR(EINVAL)); + ZFS_ENTER(zsb); ZFS_VERIFY_ZP(dzp); zilog = zsb->z_log; @@ -1918,6 +1924,9 @@ zfs_mkdir(struct inode *dip, char *dirname, vattr_t *vap, struct inode **ipp, (vsecp || IS_EPHEMERAL(uid) || IS_EPHEMERAL(gid))) return (SET_ERROR(EINVAL)); + if (dirname == NULL) + return (SET_ERROR(EINVAL)); + ZFS_ENTER(zsb); ZFS_VERIFY_ZP(dzp); zilog = zsb->z_log; @@ -2080,6 +2089,9 @@ zfs_rmdir(struct inode *dip, char *name, struct inode *cwd, cred_t *cr, int zflg = ZEXISTS; boolean_t waited = B_FALSE; + if (name == NULL) + return (SET_ERROR(EINVAL)); + ZFS_ENTER(zsb); ZFS_VERIFY_ZP(dzp); zilog = zsb->z_log; @@ -3382,6 +3394,9 @@ zfs_rename(struct inode *sdip, char *snm, struct inode *tdip, char *tnm, int zflg = 0; boolean_t waited = B_FALSE; + if (snm == NULL || tnm == NULL) + return (SET_ERROR(EINVAL)); + ZFS_ENTER(zsb); ZFS_VERIFY_ZP(sdzp); zilog = zsb->z_log; @@ -3726,6 +3741,9 @@ zfs_symlink(struct inode *dip, char *name, vattr_t *vap, char *link, ASSERT(S_ISLNK(vap->va_mode)); + if (name == NULL) + return (SET_ERROR(EINVAL)); + ZFS_ENTER(zsb); ZFS_VERIFY_ZP(dzp); zilog = zsb->z_log; @@ -3926,6 +3944,9 @@ zfs_link(struct inode *tdip, struct inode *sip, char *name, cred_t *cr, #endif ASSERT(S_ISDIR(tdip->i_mode)); + if (name == NULL) + return (SET_ERROR(EINVAL)); + ZFS_ENTER(zsb); ZFS_VERIFY_ZP(dzp); zilog = zsb->z_log;