Skip to content

Commit

Permalink
vcsm: properly handle too many CMA allocation attempts
Browse files Browse the repository at this point in the history
Fixes #690
  • Loading branch information
doe300 authored and popcornmix committed May 13, 2021
1 parent 45a0022 commit d4a960e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions host_applications/linux/libs/sm/user-vcsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,13 @@ unsigned int vcsm_malloc_cache( unsigned int size, VCSM_CACHE_TYPE_T cache, cons
);

payload = vcsm_payload_list_get();
if (!payload)
{
vcos_log_error("[%s]: max number of allocations reached: %d", __func__, VCSM_PAYLOAD_ELEM_MAX);
munmap(usr_ptr, alloc.size);
vcsm_free(alloc.handle);
return 0;
}
payload->handle = handle;
payload->fd = alloc.handle;
payload->vc_handle = alloc.vc_handle;
Expand Down Expand Up @@ -2308,6 +2315,13 @@ unsigned int vcsm_import_dmabuf( int dmabuf, const char *name )
import.handle );

payload = vcsm_payload_list_get();
if (!payload)
{
vcos_log_error("[%s]: max number of allocations reached: %d", __func__, VCSM_PAYLOAD_ELEM_MAX);
munmap(usr_ptr, import.size);
vcsm_free(import.handle);
return 0;
}
payload->handle = handle;
payload->fd = import.handle;
payload->vc_handle = import.vc_handle;
Expand Down

0 comments on commit d4a960e

Please sign in to comment.