From aed0e9f3e4db75f4b622e1f0623fe61a94a43dc2 Mon Sep 17 00:00:00 2001 From: cao Date: Tue, 25 Oct 2016 04:37:38 +0800 Subject: [PATCH] Fix coverity defects: CID 147511, 147513 CID 147511: Type:Dereference before null check CID 147513: Type:Dereference before null check Reviewed-by: Brian Behlendorf Signed-off-by: cao.xuewen Closes #5306 --- cmd/zdb/zdb.c | 2 +- lib/libshare/nfs.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index 7a0f55f75..b9b0b29bc 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -3290,7 +3290,7 @@ zdb_vdev_lookup(vdev_t *vdev, char *path) return (NULL); vdev = vdev->vdev_child[i]; - if (*s == '\0') + if (s && *s == '\0') return (vdev); return (zdb_vdev_lookup(vdev, s+1)); diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 58b4c8880..9d548dccc 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -532,8 +532,10 @@ nfs_is_share_active(sa_share_impl_t impl_share) nfs_exportfs_temp_fp = fdopen(fd, "r"); - if (nfs_exportfs_temp_fp == NULL || - fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) { + if (nfs_exportfs_temp_fp == NULL) + return (B_FALSE); + + if (fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) { fclose(nfs_exportfs_temp_fp); return (B_FALSE); }