Commit a5309547 authored by Suman Anna's avatar Suman Anna Committed by Hari Kanigeri

SYSLINK: ipc - minor bug fixes in listmp_sharedmemory module

This patch includes couple of minor bug fixes in listmp_sharedmemory module.
NULL config parameter is supported in the listmp_sharedmemory_setup function,
and couple of additional error checks have been added.
Signed-off-by: default avatarSuman Anna <s-anna@ti.com>
parent 721b2859
...@@ -223,9 +223,9 @@ int listmp_sharedmemory_setup(struct listmp_config *config) ...@@ -223,9 +223,9 @@ int listmp_sharedmemory_setup(struct listmp_config *config)
gt_1trace(listmpshm_debugmask, GT_ENTER, "ListMPSharedmemsetup", gt_1trace(listmpshm_debugmask, GT_ENTER, "ListMPSharedmemsetup",
config); config);
if (WARN_ON(config == NULL)) { if (config == NULL) {
status = -EINVAL; memcpy(config, &listmp_sharedmemory_state.default_cfg,
goto exit; sizeof(struct listmp_config));
} }
if (WARN_ON(config->max_name_len == 0)) { if (WARN_ON(config->max_name_len == 0)) {
status = -EINVAL; status = -EINVAL;
...@@ -238,8 +238,10 @@ int listmp_sharedmemory_setup(struct listmp_config *config) ...@@ -238,8 +238,10 @@ int listmp_sharedmemory_setup(struct listmp_config *config)
params.max_name_len = config->max_name_len; params.max_name_len = config->max_name_len;
/* Create the nameserver for modules */ /* Create the nameserver for modules */
nshandle = nameserver_create(LISTMP_SHAREDMEMORY_NAMESERVER, &params); nshandle = nameserver_create(LISTMP_SHAREDMEMORY_NAMESERVER, &params);
if (unlikely(nshandle == NULL)) if (unlikely(nshandle == NULL)) {
status = LISTMPSHAREDMEMORY_E_FAIL;
goto exit; goto exit;
}
listmp_sharedmemory_state.ns_handle = nshandle; listmp_sharedmemory_state.ns_handle = nshandle;
/* Construct the list object */ /* Construct the list object */
...@@ -337,7 +339,6 @@ exit: ...@@ -337,7 +339,6 @@ exit:
void listmp_sharedmemory_params_init(listmp_sharedmemory_handle handle, void listmp_sharedmemory_params_init(listmp_sharedmemory_handle handle,
listmp_sharedmemory_params *params) listmp_sharedmemory_params *params)
{ {
int status = 0;
listmp_sharedmemory_object *object = NULL; listmp_sharedmemory_object *object = NULL;
struct listmp_sharedmemory_obj *obj = NULL; struct listmp_sharedmemory_obj *obj = NULL;
...@@ -345,10 +346,8 @@ void listmp_sharedmemory_params_init(listmp_sharedmemory_handle handle, ...@@ -345,10 +346,8 @@ void listmp_sharedmemory_params_init(listmp_sharedmemory_handle handle,
"listmp_sharedmemory_params_init", handle, params); "listmp_sharedmemory_params_init", handle, params);
BUG_ON(params == NULL); BUG_ON(params == NULL);
if (WARN_ON(params == NULL)) { if (WARN_ON(params == NULL))
status = -EINVAL;
goto exit; goto exit;
}
if (handle == NULL) { if (handle == NULL) {
memcpy(params, memcpy(params,
...@@ -411,14 +410,18 @@ listmp_sharedmemory_handle listmp_sharedmemory_create( ...@@ -411,14 +410,18 @@ listmp_sharedmemory_handle listmp_sharedmemory_create(
_listmp_sharedmemory_create(params, true); _listmp_sharedmemory_create(params, true);
obj = (struct listmp_sharedmemory_obj *)handle->obj; obj = (struct listmp_sharedmemory_obj *)handle->obj;
if (obj == NULL) {
status = LISTMPSHAREDMEMORY_E_FAIL;
goto exit;
}
obj->listmp_elem->next = (struct listmp_elem *) (sharedregion_get_srptr( obj->listmp_elem->next = (struct listmp_elem *) (sharedregion_get_srptr(
(void *)obj->listmp_elem, obj->index)); (void *)obj->listmp_elem, obj->index));
obj->listmp_elem->prev = (struct listmp_elem *) (sharedregion_get_srptr( obj->listmp_elem->prev = (struct listmp_elem *) (sharedregion_get_srptr(
(void *)obj->listmp_elem, obj->index)); (void *)obj->listmp_elem, obj->index));
exit: exit:
gt_1trace(listmpshm_debugmask, GT_LEAVE, "listmp_sharedmemory_create", gt_2trace(listmpshm_debugmask, GT_LEAVE, "listmp_sharedmemory_create",
handle); status, handle);
return (listmp_sharedmemory_handle) handle; return (listmp_sharedmemory_handle) handle;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment