soc: qcom: Fix memcpy operations in ramdump_read
Currently, for device memory addresses, which are not aligned on 8 byte boundary, ramdump_read() copies the bytes till the start of next aligned address. However, this calculation does not take into account the case, where copy_size is less that the number of bytes till next alignment. This causes memcpy to copy device memory to region, which is outside of the allocated buffer. Fix this by copying only the copy_size buffer for this case. Change-Id: I918ab5886d664f89c0eebd99972f5b9960e1ae00 Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org>
This commit is contained in:
@@ -241,6 +241,8 @@ static ssize_t ramdump_read(struct file *filep, char __user *buf, size_t count,
|
|||||||
|
|
||||||
if ((unsigned long)device_mem & 0x7) {
|
if ((unsigned long)device_mem & 0x7) {
|
||||||
bytes_before = 8 - ((unsigned long)device_mem & 0x7);
|
bytes_before = 8 - ((unsigned long)device_mem & 0x7);
|
||||||
|
bytes_before = min_t(unsigned long, (unsigned long)copy_size,
|
||||||
|
bytes_before);
|
||||||
memcpy_fromio(alignbuf, device_mem, bytes_before);
|
memcpy_fromio(alignbuf, device_mem, bytes_before);
|
||||||
device_mem += bytes_before;
|
device_mem += bytes_before;
|
||||||
alignbuf += bytes_before;
|
alignbuf += bytes_before;
|
||||||
|
|||||||
Reference in New Issue
Block a user