diag: masks: Use realloc() to increase mask in diag_cmd_get_event_mask()

Rather than calling malloc() and free() use realloc() to increase mask
size in diag_cmd_get_event_mask().

Signed-off-by: Eyal Ilsar <eilsar@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Eyal Ilsar
2018-04-03 04:19:14 +03:00
committed by Bjorn Andersson
parent 49614e6675
commit fbe328fa96

View File

@@ -565,14 +565,13 @@ int diag_cmd_update_event_mask(uint16_t num_bits, const uint8_t *mask)
void *tmp_buf;
if (num_bits > event_max_num_bits ) {
tmp_buf = malloc(BITS_TO_BYTES(num_bits));
tmp_buf = realloc(event_mask.ptr, BITS_TO_BYTES(num_bits));
if (!tmp_buf) {
event_mask.status = DIAG_CTRL_MASK_INVALID;
warn("Failed to reallocate event mask\n");
return -errno;
}
free(event_mask.ptr);
event_mask.ptr = tmp_buf;
event_max_num_bits = num_bits;