[mpp_buffer]: avoid accessing violation address

Sometimes the offset or the offset plus the size is beyond the
buffer area. It would be better to raise an error and stopping
the future step rather than the kernel halt it.

Change-Id: I32d6f05736c874d56e1e9f77505f16ca3a2c01ac
Signed-off-by: Randy Li <randy.li@rock-chips.com>
This commit is contained in:
Randy Li
2017-04-19 09:31:57 +08:00
committed by Herman Chen
parent f98cd806ac
commit 66aa10082c

View File

@@ -147,6 +147,8 @@ MPP_RET mpp_buffer_write_with_caller(MppBuffer buffer, size_t offset, void *data
return MPP_OK;
MppBufferImpl *p = (MppBufferImpl*)buffer;
if (offset + size > p->info.size)
return MPP_ERR_VALUE;
if (NULL == p->info.ptr)
mpp_buffer_mmap(p, caller);