Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8269b4cd authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-fg: fix fuel gauge memory reads



Currently the fuel gauge helper function for SRAM reads
(fg_sub_mem_read) has a bug where it could potentially cause a buffer
overrun.

If a read starts on a non word aligned byte, it will always read the
rest of the word, regardless of the buffer size provided. For example,
if one byte from the address 0x401 was read, the sub mem read function
will actually copy the data from 0x401 to 0x403 to the buffer,
regardless of the length.

Fix this by using the minimum of the remaining word length and the
buffer length to determine how many bytes to copy to the result buffer.

CRs-Fixed: 770918
Change-Id: I74858242635f7710abc30c0f6e7fca8037a19ab8
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent e48ac7ed
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment