From b1eec00904a22bd6600a2853709ca50faa56ea24 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Thu, 10 Nov 2022 09:09:35 -0500 Subject: [PATCH] Cleanup: Suppress Coverity dereference before/after NULL check reports f224eddf922a33ca4b86d83148e9e6fa155fc290 began dereferencing a NULL checked pointer in zpl_vap_init(), which made Coverity complain because either the dereference is unsafe or the NULL check is unnecessary. Upon inspection, this pointer is guaranteed to never be NULL because it is from the Linux kernel VFS. The calls into ZFS simply would not make sense if this pointer were NULL, so the NULL check is unnecessary. Reported-by: Coverity (CID 1527260) Reported-by: Coverity (CID 1527262) Reviewed-by: Mariusz Zaborski Reviewed-by: Youzhong Yang Signed-off-by: Richard Yao Closes #14170 --- module/os/linux/zfs/zpl_inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index 6f4718f7d5..93eae72015 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -121,7 +121,7 @@ zpl_vap_init(vattr_t *vap, struct inode *dir, umode_t mode, cred_t *cr, vap->va_uid = zfs_vfsuid_to_uid((struct user_namespace *)mnt_ns, zfs_i_user_ns(dir), crgetuid(cr)); - if (dir && dir->i_mode & S_ISGID) { + if (dir->i_mode & S_ISGID) { vap->va_gid = KGID_TO_SGID(dir->i_gid); if (S_ISDIR(mode)) vap->va_mode |= S_ISGID;