1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

vacuum: free temporary allocated memory correctly in ctdb_process_delete_list().

Add a common exit point for cleanup.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-By: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 11d728465a9c635e1829abaae17e2f7720433b69)
This commit is contained in:
Michael Adam 2012-12-17 17:31:55 +01:00 committed by Amitay Isaacs
parent afb22c1e25
commit 9778ce4b06

View File

@ -736,7 +736,8 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
offsetof(struct ctdb_marshall_buffer, data)); offsetof(struct ctdb_marshall_buffer, data));
if (recs->records == NULL) { if (recs->records == NULL) {
DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
return -1; ret = -1;
goto done;
} }
recs->records->db_id = ctdb_db->db_id; recs->records->db_id = ctdb_db->db_id;
@ -761,7 +762,8 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
&nodemap); &nodemap);
if (ret != 0) { if (ret != 0) {
DEBUG(DEBUG_ERR,(__location__ " unable to get node map\n")); DEBUG(DEBUG_ERR,(__location__ " unable to get node map\n"));
return -1; ret = -1;
goto done;
} }
active_nodes = list_of_active_nodes(ctdb, nodemap, active_nodes = list_of_active_nodes(ctdb, nodemap,
@ -784,7 +786,8 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
DEBUG(DEBUG_ERR, ("Failed to delete records on " DEBUG(DEBUG_ERR, ("Failed to delete records on "
"node %u: ret[%d] res[%d]\n", "node %u: ret[%d] res[%d]\n",
active_nodes[i], ret, res)); active_nodes[i], ret, res));
return -1; ret = -1;
goto done;
} }
/* /*
@ -817,7 +820,8 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
if (recdata.dsize < sizeof(struct ctdb_ltdb_header)) { if (recdata.dsize < sizeof(struct ctdb_ltdb_header)) {
DEBUG(DEBUG_CRIT,(__location__ " bad ltdb record\n")); DEBUG(DEBUG_CRIT,(__location__ " bad ltdb record\n"));
return -1; ret = -1;
goto done;
} }
rechdr = (struct ctdb_ltdb_header *)recdata.dptr; rechdr = (struct ctdb_ltdb_header *)recdata.dptr;
recdata.dptr += sizeof(*rechdr); recdata.dptr += sizeof(*rechdr);
@ -842,9 +846,6 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
} }
} }
/* free nodemap and active_nodes */
talloc_free(nodemap);
if (vdata->delete_left > 0) { if (vdata->delete_left > 0) {
/* /*
* The only records remaining in the tree are those * The only records remaining in the tree are those
@ -876,7 +877,13 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
(unsigned)vdata->delete_left)); (unsigned)vdata->delete_left));
} }
return 0; ret = 0;
done:
/* free recs / nodemap / active_nodes */
talloc_free(recs);
return ret;
} }
/** /**