Skip to content

Commit

Permalink
Fix optional "force" arg handing in zfs_ioc_pool_sync()
Browse files Browse the repository at this point in the history
The fnvlist_lookup_boolean_value() function should not be used
to check the force argument since it's optional.  It may not be
provided or may have been created with the wrong flags.

Signed-off-by: Brian Behlendorf <[email protected]>
Issue #11281
  • Loading branch information
behlendorf committed Dec 8, 2020
1 parent 1a735e7 commit bd994ff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6648,14 +6648,17 @@ static int
zfs_ioc_pool_sync(const char *pool, nvlist_t *innvl, nvlist_t *onvl)
{
int err;
boolean_t force = B_FALSE;
boolean_t rc, force = B_FALSE;
spa_t *spa;

if ((err = spa_open(pool, &spa, FTAG)) != 0)
return (err);

if (innvl)
force = fnvlist_lookup_boolean_value(innvl, "force");
if (innvl) {
err = nvlist_lookup_boolean_value(innvl, "force", &rc);
if (err == 0)
force = rc;
}

if (force) {
spa_config_enter(spa, SCL_CONFIG, FTAG, RW_WRITER);
Expand All @@ -6666,7 +6669,7 @@ zfs_ioc_pool_sync(const char *pool, nvlist_t *innvl, nvlist_t *onvl)

spa_close(spa, FTAG);

return (err);
return (0);
}

/*
Expand Down

0 comments on commit bd994ff

Please sign in to comment.