mirror of
https://github.com/linux-msm/diag.git
synced 2026-02-25 13:11:48 -08:00
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:
committed by
Bjorn Andersson
parent
49614e6675
commit
fbe328fa96
3
masks.c
3
masks.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user