From 0a8f18f9327a6275759393c5fc2f14664f172add Mon Sep 17 00:00:00 2001 From: cao Date: Sat, 1 Oct 2016 06:56:17 +0800 Subject: [PATCH] Fix coverity defects: CID 147563, 147560 coverity scan CID:147563, Type:dereference null return value coverity scan CID:147560, Type:dereference null return value Reviewed-by: Richard Laager Reviewed-by: Brian Behlendorf Signed-off-by: cao.xuewen Closes #5168 --- lib/libzfs/libzfs_dataset.c | 5 +++++ module/zfs/dsl_dataset.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 84fe71734..6b09cb6da 100755 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -2262,6 +2262,11 @@ zfs_get_clones_nvl(zfs_handle_t *zhp) (void) strsep(&cp, "/@"); root = zfs_open(zhp->zfs_hdl, pool, ZFS_TYPE_FILESYSTEM); + if (root == NULL) { + nvlist_free(nv); + nvlist_free(value); + return (NULL); + } (void) get_clones_cb(root, &gca); } diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index d4a3a9e41..3026d8733 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -2354,6 +2354,10 @@ dsl_dataset_promote_check(void *arg, dmu_tx_t *tx) } snap = list_head(&ddpa->shared_snaps); + if (snap == NULL) { + err = SET_ERROR(ENOENT); + goto out; + } origin_ds = snap->ds; /* compute origin's new unique space */ @@ -2462,6 +2466,10 @@ dsl_dataset_promote_check(void *arg, dmu_tx_t *tx) * iterate over all bps. */ snap = list_head(&ddpa->origin_snaps); + if (snap == NULL) { + err = SET_ERROR(ENOENT); + goto out; + } err = snaplist_space(&ddpa->shared_snaps, snap->ds->ds_dir->dd_origin_txg, &ddpa->cloneusedsnap); if (err != 0)