From: Kitae Kim Date: Fri, 10 Jan 2014 02:08:28 +0000 (+0900) Subject: brillcodec: improve an exception case when requested memory size is invalid. X-Git-Tag: submit/tizen_common/20140905.094502~117^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fce9778feb00953eb213cd9c2bfed32d2ab9287b;p=sdk%2Femulator%2Femulator-kernel.git brillcodec: improve an exception case when requested memory size is invalid. In case of that the requested memory size is invalid, the next statement might be caused SEGV problem because of index value. In addition to this, some log messages are modified. Change-Id: I22820b42c714e5a5d3416b6fa118841a46dca1d8 Signed-off-by: Kitae Kim --- diff --git a/drivers/maru/maru_brillcodec.c b/drivers/maru/maru_brillcodec.c index 2a72e54f5b17..65a7193fc7b6 100644 --- a/drivers/maru/maru_brillcodec.c +++ b/drivers/maru/maru_brillcodec.c @@ -281,6 +281,7 @@ static int secure_device_memory(uint32_t ctx_id, uint32_t buf_size, index = LARGE; } else { ERROR("invalid buffer size: %x\n", buf_size); + return -1; } block = &maru_brill_codec->memory_blocks[index]; @@ -347,6 +348,8 @@ static void release_device_memory(uint32_t mem_offset) index = LARGE; } else { // error + ERROR("invalid memory offsset. offset = 0x%x.\n", (uint32_t)mem_offset); + return; } block = &maru_brill_codec->memory_blocks[index]; @@ -369,19 +372,17 @@ static void release_device_memory(uint32_t mem_offset) } found = true; - break; } } if (!found) { // can not enter here... - ERROR("there is no used memory block. offset = 0x%x.\n", (uint32_t)mem_offset); + ERROR("cannot find this memory block. offset = 0x%x.\n", (uint32_t)mem_offset); } } else { // can not enter here... - ERROR("there is no used memory block.\n"); + DEBUG("there is not any using memory block.\n"); } - mutex_unlock(&block->access_mutex); }