zdev: check for errors when removing a devtype setting

Currently, a device type setting being --removed from both the active and
persistent configuration via 'chzdev -t' can result in a scenario where
the setting is not removed from the active configuration (and an error
message is presented) but chzdev still proceeds to remove the setting from
the persistent configuration.
Update this logic so that devtype_remove_settings behaves the same way as
device_remove_settings and only perform the removal when no errors are
encountered.

Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Matthew Rosato
2022-02-02 09:19:46 -05:00
committed by Jan Höppner
parent a67888f36a
commit b5da337d1e

View File

@@ -2088,12 +2088,18 @@ static exit_code_t devtype_remove_settings(struct devtype *dt, config_t config,
found = strlist_new();
notfound = strlist_new();
if (SCOPE_ACTIVE(config))
remove_settings(dt->active_settings, names, found, notfound, 1);
if (SCOPE_ACTIVE(config)) {
rc = remove_settings(dt->active_settings, names, found,
notfound, 1);
if (rc)
goto out;
}
if (SCOPE_PERSISTENT(config)) {
remove_settings(dt->persistent_settings, names, found,
notfound, 0);
rc = remove_settings(dt->persistent_settings, names, found,
notfound, 0);
if (rc)
goto out;
}
if (!util_list_is_empty(notfound)) {
@@ -2104,6 +2110,7 @@ static exit_code_t devtype_remove_settings(struct devtype *dt, config_t config,
rc = EXIT_SETTING_NOT_FOUND;
}
out:
strlist_free(found);
strlist_free(notfound);