@@ -142,13 +142,13 @@ static int
fedfs_lookup_replication_try(admin_t host, char * const *path_array,
int request)
{
- struct admin_fsl *fsls;
- struct admin_fsn *fsn;
+ struct admin_fsl *fsls = NULL;
+ struct admin_fsn *fsn = NULL;
int status, err;
+ status = EXIT_FAILURE;
switch (request) {
case 0:
- fsls = NULL;
err = admin_lookup_replication_none(host, path_array, &fsn);
break;
case 1:
@@ -159,9 +159,11 @@ fedfs_lookup_replication_try(admin_t host, char * const *path_array,
err = admin_lookup_replication_nsdb(host, path_array,
&fsn, &fsls);
break;
+ default:
+ xlog(L_ERROR, "Unrecognized request");
+ goto out;
}
- status = EXIT_FAILURE;
switch (err) {
case 0:
break;
@@ -185,23 +187,23 @@ fedfs_lookup_replication_try(admin_t host, char * const *path_array,
printf("NSDB: %s:%u\n",
fsn->af_nsdb.an_hostname,
fsn->af_nsdb.an_port);
- admin_free_fsn(fsn);
- if (request > 0) {
+ if (request > 0)
fedfs_lookup_replication_print_fsls(fsls);
- admin_free_fsls(fsls);
- }
status = EXIT_SUCCESS;
break;
case FEDFS_ERR_NSDB_LDAP_VAL:
fprintf(stderr, "LDAP result code (%d): %s\n",
admin_ldaperr(host),
ldap_err2string(admin_ldaperr(host)));
+ break;
case FEDFS_ERR_NSDB_PARAMS:
printf("No connection parameters found\n");
break;
default:
nsdb_print_fedfsstatus(admin_status(host));
}
+ admin_free_fsls(fsls);
+ admin_free_fsn(fsn);
out:
return status;
Ensure "fsls" and "fsn" are freed before returning. Fixes: b7c5e005319bdefa93d2158c9bd5de67c03e6a60 Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- src/fedfsc/fedfs-lookup-replication.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)