aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManoj Prabhu B <bmanoj@codeaurora.org>2018-06-27 16:05:57 +0530
committerPrashanth Swaminathan <prashanthsw@google.com>2018-08-31 13:26:55 -0700
commitdbeb9a83bc0f62fd939d4560ed904d08fc3650d0 (patch)
tree5c841e48b1dd90ff87003ccbcf73ca25e6fe397d
parent59c94cd72ac55c778ea7c2dd3cbd42ac46454eb2 (diff)
downloadqcom-msm8x53-v3.18-dbeb9a83bc0f62fd939d4560ed904d08fc3650d0.tar.gz
diag: Update mask buffer after reallocation
Currently, reallocated mask update buffers are not updated if the received mask range is more than the mask update buffer length. Update the reallocated buffer address before writing the mask to peripherals. Bug: 110941020 CRs-Fixed: 2266693 Change-Id: I6b506ce68e17b7da61926b0f9543157812a8c555 Signed-off-by: Manoj Prabhu B <bmanoj@codeaurora.org>
-rw-r--r--drivers/char/diag/diag_masks.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/char/diag/diag_masks.c b/drivers/char/diag/diag_masks.c
index ef0a324bc82..833a5fadd27 100644
--- a/drivers/char/diag/diag_masks.c
+++ b/drivers/char/diag/diag_masks.c
@@ -167,10 +167,11 @@ static void diag_send_log_mask_update(uint8_t peripheral, int equip_id)
}
mask_info->update_buf = temp;
mask_info->update_buf_len = header_len + mask_size;
+ buf = temp;
}
memcpy(buf, &ctrl_pkt, header_len);
- if (mask_size > 0)
+ if (mask_size > 0 && mask_size <= LOG_MASK_SIZE)
memcpy(buf + header_len, mask->ptr, mask_size);
mutex_unlock(&mask->lock);
@@ -254,9 +255,16 @@ static void diag_send_event_mask_update(uint8_t peripheral)
} else {
mask_info->update_buf = temp;
mask_info->update_buf_len = temp_len;
+ buf = temp;
}
}
- memcpy(buf + sizeof(header), mask_info->ptr, num_bytes);
+ if (num_bytes > 0 && num_bytes < mask_info->mask_len)
+ memcpy(buf + sizeof(header), mask_info->ptr, num_bytes);
+ else {
+ pr_err("diag: num_bytes(%d) is not satisfying length condition\n",
+ num_bytes);
+ goto err;
+ }
write_len += num_bytes;
break;
default:
@@ -359,6 +367,7 @@ static void diag_send_msg_mask_update(uint8_t peripheral, int first, int last)
} else {
mask_info->update_buf = temp;
mask_info->update_buf_len = temp_len;
+ buf = temp;
pr_debug("diag: In %s, successfully reallocated msg_mask update buffer to len: %d\n",
__func__, mask_info->update_buf_len);
}