Skip to content

Commit

Permalink
fix coverity defects with CID 147626-28-29
Browse files Browse the repository at this point in the history
issues:
fix coverity defects
coverity scan CID:147626, Type:Dereference before null check
coverity scan CID:147628, Type:Dereference before null check
coverity scan CID:147629, Type:Dereference before null check

Signed-off-by: cao.xuewen cao.xuewen@zte.com.cn
  • Loading branch information
heary-cao committed Oct 25, 2016
1 parent 9523b15 commit 59b4b5c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
12 changes: 4 additions & 8 deletions lib/libuutil/uu_dprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,10 @@ uu_dprintf_create(const char *name, uu_dprintf_severity_t severity,
if ((D = uu_zalloc(sizeof (uu_dprintf_t))) == NULL)
return (NULL);

if (name != NULL) {
D->uud_name = strdup(name);
if (D->uud_name == NULL) {
uu_free(D);
return (NULL);
}
} else {
D->uud_name = NULL;
D->uud_name = strdup(name);
if (D->uud_name == NULL) {
uu_free(D);
return (NULL);
}

D->uud_severity = severity;
Expand Down
19 changes: 9 additions & 10 deletions module/zfs/zfs_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ zfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out,
* If we are doing a spa_tryimport() or in recovery mode,
* ignore errors.
*/
if (spa_load_state(spa) == SPA_LOAD_TRYIMPORT ||
if (spa != NULL ||
spa_load_state(spa) == SPA_LOAD_TRYIMPORT ||
spa_load_state(spa) == SPA_LOAD_RECOVER)
return;

Expand Down Expand Up @@ -272,15 +273,13 @@ zfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out,
FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT, DATA_TYPE_INT32,
spa_load_state(spa), NULL);

if (spa != NULL) {
fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE,
DATA_TYPE_STRING,
spa_get_failmode(spa) == ZIO_FAILURE_MODE_WAIT ?
FM_EREPORT_FAILMODE_WAIT :
spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE ?
FM_EREPORT_FAILMODE_CONTINUE : FM_EREPORT_FAILMODE_PANIC,
NULL);
}
fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE,
DATA_TYPE_STRING,
spa_get_failmode(spa) == ZIO_FAILURE_MODE_WAIT ?
FM_EREPORT_FAILMODE_WAIT :
spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE ?
FM_EREPORT_FAILMODE_CONTINUE : FM_EREPORT_FAILMODE_PANIC,
NULL);

if (vd != NULL) {
vdev_t *pvd = vd->vdev_parent;
Expand Down
3 changes: 1 addition & 2 deletions module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -4112,8 +4112,7 @@ zfs_putpage(struct inode *ip, struct page *pp, struct writeback_control *wbc)
* writepages() normally handles the entire commit for
* performance reasons.
*/
if (zsb->z_log != NULL)
zil_commit(zsb->z_log, zp->z_id);
zil_commit(zsb->z_log, zp->z_id);
}

ZFS_EXIT(zsb);
Expand Down

0 comments on commit 59b4b5c

Please sign in to comment.