Skip to content

Commit

Permalink
DAOS-13906 engine: Check for memory allocation properly to avoid cras…
Browse files Browse the repository at this point in the history
…h. (#12635)

Fix some error handling code.

Signed-off-by: Ashley Pittman <ashley.m.pittman@intel.com>
  • Loading branch information
ashleypittman authored Jul 17, 2023
1 parent c30402f commit 2ce37ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/cart/crt_iv.c
Original file line number Diff line number Diff line change
Expand Up @@ -3305,8 +3305,11 @@ crt_iv_update_internal(crt_iv_namespace_t ivns, uint32_t class_id,
D_GOTO(exit, rc);
}

rc = iv_ops->ivo_on_get(ivns, iv_key,
0, CRT_IV_PERM_WRITE, NULL, &priv);
rc = iv_ops->ivo_on_get(ivns, iv_key, 0, CRT_IV_PERM_WRITE, NULL, &priv);
if (rc != 0) {
D_ERROR("ivo_on_get(): " DF_RC, DP_RC(rc));
D_GOTO(exit, rc);
}

if (iv_value != NULL)
rc = iv_ops->ivo_on_update(ivns, iv_key, 0,
Expand Down
5 changes: 2 additions & 3 deletions src/engine/server_iv.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ ivc_on_get(crt_iv_namespace_t ivns, crt_iv_key_t *iv_key,

class = entry->iv_class;
if (iv_value) {
rc = class->iv_class_ops->ivc_value_alloc(entry, &key,
iv_value);
rc = class->iv_class_ops->ivc_value_alloc(entry, &key, iv_value);
if (rc)
D_GOTO(out, rc);
}
Expand All @@ -609,7 +608,7 @@ ivc_on_get(crt_iv_namespace_t ivns, crt_iv_key_t *iv_key,
D_ALLOC_PTR(priv_entry);
if (priv_entry == NULL) {
class->iv_class_ops->ivc_ent_put(entry, entry_priv_val);
D_GOTO(out, rc);
D_GOTO(out, rc = -DER_NOMEM);
}

priv_entry->priv = entry_priv_val;
Expand Down

0 comments on commit 2ce37ca

Please sign in to comment.