Commit f20f616f authored by lio's avatar lio Committed by Philippe Gerum
Browse files

lib:fix possible returning EINVAL when evl_attach* called by SCHED_RR threads



When evl_attach_thread() was called,  a local stack variable *attrs* will copy-
from-user to linux-evl. The problem is that *attrs* initializes only two of its
members:attrs.sched_policy and attrs.sched_priority, but none of the other
members are initialized.

These uninitialized may be "zero" or any other random values, for example:
attrs->sched_rr_quantum may be some none-zero value when the threads under
discussion is a SCHED_RR task.
In this case, *attrs* copyed to linux-evl in *thread_common_ioctl()*, and
attrs->sched_rr_quantum is none-zero value; then fllowed call *set_time_slice*
will lead to a -EINVAL return for meet *quantum <= evl_get_clock_gravity()*.

This patch will initialize all members of *attrs* to zero.
Signed-off-by: default avatarlio <liu.hailong6@zte.com.cn>
parent f2a20b51
......@@ -119,6 +119,7 @@ int evl_attach_thread(int flags, const char *fmt, ...)
pthread_once(&atfork_once, do_atfork_once);
memset(&attrs, 0, sizeof(attrs));
attrs.sched_policy = policy;
attrs.sched_priority = priority;
ret = oob_ioctl(efd, EVL_THRIOC_SET_SCHEDPARAM, &attrs);
......
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