diff options
author | cao <[email protected]> | 2016-10-21 02:49:50 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-10-20 11:49:50 -0700 |
commit | 9d01680430377b39dc34aaaf6ef315c49b3943cc (patch) | |
tree | 65b5ff873b8c6460122831772f227d1d08eac162 /lib | |
parent | 5a6765cf8cad21d22dc172b4089b655c9270d16a (diff) |
Fix coverity defects: CID 147551, 147552
CID 147551: Type:dereference null return value
CID 147552: Type:dereference null return value
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: cao.xuewen <[email protected]>
Closes #5279
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_dataset.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 7d8179d1f..e0f84af50 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -3663,6 +3663,8 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props) char errbuf[1024]; nvpair_t *elem; nvlist_t *errors; + zpool_handle_t *zpool_hdl; + char pool[ZFS_MAX_DATASET_NAME_LEN]; (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot create snapshots ")); @@ -3685,11 +3687,12 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props) * get pool handle for prop validation. assumes all snaps are in the * same pool, as does lzc_snapshot (below). */ - char pool[ZFS_MAX_DATASET_NAME_LEN]; elem = nvlist_next_nvpair(snaps, NULL); (void) strlcpy(pool, nvpair_name(elem), sizeof (pool)); pool[strcspn(pool, "/@")] = '\0'; - zpool_handle_t *zpool_hdl = zpool_open(hdl, pool); + zpool_hdl = zpool_open(hdl, pool); + if (zpool_hdl == NULL) + return (-1); if (props != NULL && (props = zfs_valid_proplist(hdl, ZFS_TYPE_SNAPSHOT, |