aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcao <[email protected]>2016-10-21 02:49:50 +0800
committerBrian Behlendorf <[email protected]>2016-10-20 11:49:50 -0700
commit9d01680430377b39dc34aaaf6ef315c49b3943cc (patch)
tree65b5ff873b8c6460122831772f227d1d08eac162
parent5a6765cf8cad21d22dc172b4089b655c9270d16a (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
-rw-r--r--lib/libzfs/libzfs_dataset.c7
-rw-r--r--module/zfs/zfs_ioctl.c4
2 files changed, 9 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,
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c
index 549a83116..e3166a40e 100644
--- a/module/zfs/zfs_ioctl.c
+++ b/module/zfs/zfs_ioctl.c
@@ -2773,6 +2773,10 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
}
pair = nvlist_next_nvpair(dummy, NULL);
+ if (pair == NULL) {
+ nvlist_free(dummy);
+ return (SET_ERROR(EINVAL));
+ }
err = zfs_prop_set_special(zc->zc_name, source, pair);
nvlist_free(dummy);
if (err != -1)