brillcodec: improve an exception case when requested memory size is invalid. 21/19221/1
authorKitae Kim <kt920.kim@samsung.com>
Fri, 10 Jan 2014 02:08:28 +0000 (11:08 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Wed, 9 Apr 2014 04:47:06 +0000 (13:47 +0900)
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 <kt920.kim@samsung.com>
drivers/maru/maru_brillcodec.c

index 2a72e54f5b175580807f8ed77f89dc955750ecd8..65a7193fc7b66c468c299e392296f036c14500c2 100644 (file)
@@ -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);
 }