Skip to content

Commit

Permalink
DAOS-13996 pool: Fix invalid D_FREE in pool_glance (#12683)
Browse files Browse the repository at this point in the history
pool_glance should only free map_buf if ds_pool_svc_load returns zero.
The segfault might be triggered because ds_pool_svc_load returned
DER_UNINIT; it is unknown that what actually happened. This patch fixes
the D_FREE logic.

ds_pool_svc_load does not need to free map_buf in any case. It is likely
a merge error. This patch removes the unnecessary D_FREE in
ds_pool_svc_load.

Signed-off-by: Li Wei <[email protected]>
  • Loading branch information
liw authored Jul 31, 2023
1 parent fc9d90b commit 02a43c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/pool/srv_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1540,8 +1540,6 @@ ds_pool_svc_load(struct rdb_tx *tx, uuid_t uuid, rdb_path_t *root, uint32_t *glo
*global_version_out = global_version;
*map_buf_out = map_buf;
*map_version_out = map_version;
if (rc != 0)
D_FREE(map_buf);
out:
return rc;
}
Expand Down Expand Up @@ -7730,4 +7728,4 @@ struct cont_svc *
ds_pool_ps2cs(struct ds_pool_svc *ds_svc)
{
return pool_ds2svc(ds_svc)->ps_cont_svc;
}
}
7 changes: 4 additions & 3 deletions src/pool/srv_pool_check.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2022 Intel Corporation.
* (C) Copyright 2022-2023 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -84,15 +84,16 @@ pool_glance(uuid_t uuid, char *path, struct ds_pool_clue *clue_out)
}

rc = ds_pool_svc_load(&tx, uuid, &root, &global_version, &map_buf, &clue.psc_map_version);
if (rc == DER_UNINIT) {
if (rc == 0) {
D_FREE(map_buf);
} else if (rc == DER_UNINIT) {
clue.psc_map_version = 0;
rc = 0;
} else if (rc != 0) {
goto out_label;
}

memcpy(clue_out->pc_svc_clue, &clue, sizeof(clue));
D_FREE(map_buf);
out_label:
if (rc != 0) {
D_FREE(clue_out->pc_label);
Expand Down

0 comments on commit 02a43c1

Please sign in to comment.