Commit 3fbde495 authored by Suman Anna's avatar Suman Anna Committed by Hari Kanigeri

SYSLINK: ipc - fix issues with nameserver_get functions

This patch fixes multiple issues with the nameserver_get and related
functions. The patch includes the following main changes.
	- nameserver_remote_get function is called only for valid
		remote notify handles in nameserver_get. Additional
		error checks have also been added.
	- Additional WARN_ONs and error checks have been added for
		input arguments in nameserver_remote_get function.
	- nameserver_remotenotify_message structure misalignment has
		been fixed. This issue is causing the remote processor
		to return wrong values when queried.
	- Additional error check has been added to ensure that there
		is a valid buffer to copy after receiving a response
		from the remote processor in nameserver_remotenotify_get
		function.
Signed-off-by: default avatarSuman Anna <s-anna@ti.com>
parent 42581ff9
...@@ -856,9 +856,12 @@ int nameserver_get(void *handle, const char *name, ...@@ -856,9 +856,12 @@ int nameserver_get(void *handle, const char *name,
if (i == local_proc_id) if (i == local_proc_id)
continue; continue;
if (nameserver_state.remote_handle_list[i] == NULL)
continue;
retval = nameserver_remote_get( retval = nameserver_remote_get(
nameserver_state.remote_handle_list[i], nameserver_state.remote_handle_list[i],
temp_obj->name, name, buffer, length); temp_obj->name, name, buffer, length);
if (retval > 0 || ((retval < 0) && if (retval > 0 || ((retval < 0) &&
(retval != -ENOENT))) /* Got the value */ (retval != -ENOENT))) /* Got the value */
break; break;
...@@ -888,7 +891,8 @@ int nameserver_get(void *handle, const char *name, ...@@ -888,7 +891,8 @@ int nameserver_get(void *handle, const char *name,
} }
exit: exit:
printk(KERN_ERR "nameserver_get status:%x \n", retval); if (retval < 0)
printk(KERN_ERR "nameserver_get failed: status=%x \n", retval);
return retval; return retval;
} }
EXPORT_SYMBOL(nameserver_get); EXPORT_SYMBOL(nameserver_get);
......
...@@ -30,7 +30,13 @@ int nameserver_remote_get(const struct nameserver_remote_object *handle, ...@@ -30,7 +30,13 @@ int nameserver_remote_get(const struct nameserver_remote_object *handle,
{ {
s32 retval = 0; s32 retval = 0;
if (WARN_ON(instance_name == NULL)) { if (handle == NULL) {
retval = -EINVAL;
goto exit;
}
if (WARN_ON((instance_name == NULL) || (name == NULL)
|| (value == NULL))) {
retval = -EINVAL; retval = -EINVAL;
goto exit; goto exit;
} }
......
...@@ -65,7 +65,6 @@ struct nameserver_remotenotify_message { ...@@ -65,7 +65,6 @@ struct nameserver_remotenotify_message {
u32 request; u32 request;
u32 response; u32 response;
u32 request_status; u32 request_status;
u32 response_status;
u32 value; u32 value;
u32 value_len; u32 value_len;
char instance_name[32]; char instance_name[32];
...@@ -369,13 +368,16 @@ int nameserver_remotenotify_get(void *rhandle, ...@@ -369,13 +368,16 @@ int nameserver_remotenotify_get(void *rhandle,
goto exit; goto exit;
} }
if (!value_len) {
retval = -ENOENT;
goto exit;
}
if (value_len == sizeof(u32)) if (value_len == sizeof(u32))
memcpy((void *)value, memcpy((void *)value, (void *) &(obj->msg[offset]->value),
(void *) &(obj->msg[offset]->value),
sizeof(u32)); sizeof(u32));
else else
memcpy((void *)value, memcpy((void *)value, (void *)&(obj->msg[offset]->value_buf),
(void *)&(obj->msg[offset]->value_buf),
value_len); value_len);
obj->msg[offset]->request_status = false; obj->msg[offset]->request_status = false;
......
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