PD#170543: codec_mm: fix some coverity error.
fix some coverity error
Change-Id: Idf234f08bc6d7522fdeb04c14956d046c94012c4
Signed-off-by: Peng Yixin <yixin.peng@amlogic.com>
void *buf, *getbuf = NULL;
if (size < PAGE_SIZE) {
- void *getbuf = (void *)__get_free_page(GFP_KERNEL);
+ getbuf = (void *)__get_free_page(GFP_KERNEL);
if (!getbuf)
return -ENOMEM;
ret = -1;
}
if (ret > 0 && getbuf != NULL) {
- int ret = min_t(int, ret, size);
+ ret = min_t(int, ret, size);
strncpy(sbuf, buf, ret);
}
if (!have_samed)
keep_id = -1;
}
+ if (codec_mm_get_keep_debug_mode() & 1) {
+ /*keeped info */
+ pr_err("codec_mm_keeper_mask_keep_mem %p id=%d\n",
+ mem_handle, keep_id);
+ }
if (keep_id < 0 || have_samed) {
if (type == MEM_TYPE_CODEC_MM_SCATTER)
ret = codec_mm_scatter_dec_keeper_user(mem_handle, 0);
pr_err("keep mem failed because keep buffer fulled!!!\n");
}
spin_unlock_irqrestore(&mgr->lock, flags);
- if (codec_mm_get_keep_debug_mode() & 1) {
- /*keeped info */
- pr_err("codec_mm_keeper_mask_keep_mem %p id=%d\n",
- mem_handle, keep_id);
- }
+
return keep_id;
}
EXPORT_SYMBOL(codec_mm_keeper_mask_keep_mem);
page_sid_type sid = SLOT_TO_SID(slot);
- if (sid < 0 || sid > MAX_SID) {
+ if (sid > MAX_SID) {
ERR_LOG("ERROR sid %d", sid);
return -1;
}
{
struct codec_mm_slot *fslot, *slot;
- if (!VALID_SID(sid))
+ if (!VALID_SID(sid) || SID_OF_ONEPAGE(sid))
return NULL;
codec_mm_list_lock(smgt);
fslot = smgt->slot_list_map[sid];
int need = num;
int can_alloced;
phy_addr_type page;
- int tryn = slot->page_num;
+ int tryn;
int i;
if (!slot || !slot->pagemap)
return -1;
if (slot->alloced_page_num >= slot->page_num)
return -2;
+ tryn = slot->page_num;
can_alloced = slot->page_num - slot->alloced_page_num;
need = need > can_alloced ? can_alloced : need;
i = slot->next_bit;
case CONFIG_TYPE_BOOL:
ret = snprintf(buf, size, "%s",
config->pboolval ? "true" : "false");
+ break;
case CONFIG_TYPE_I32:
ret = snprintf(buf, size, "%d", config->ival);
break;
struct list_head *node_list, *next;
if (mode & LIST_MODE_PATH_PREFIX) {
- if (node->depth > 0)/*not root.*/
+ if (node->depth > 0) {/*not root.*/
strncat(cprefix, node->name,
- MAX_PREFIX_NAME + MAX_ITEM_NAME);
+ MAX_PREFIX_NAME + MAX_ITEM_NAME - 1);
+ }
}
list_for_each_safe(node_list, next, &node->son_node_list) {
snode = list_entry(node_list,
s = min_t(int, size - 1, config->size - 1);
if (s > 0)
strncpy(dst, src, s);
- else
+ else {
ret = -3;
+ break;
+ }
ret = s;
break;
case CONFIG_TYPE_U32:
priv->access_get_cnt++;
r = copy_from_user(&io.cmd_path,
user_io->cmd_path, sizeof(io.cmd_path));
+ io.cmd_path[sizeof(io.cmd_path) - 1] = '\0';
if (r) {
r = -EIO;
break;