Commit ec69e64d authored by Christopher Friedt's avatar Christopher Friedt Committed by Fabio Baltieri
Browse files

posix: pthread_setspecific: fix for coverity issue cid 334906



* return EINVAL if pthread_self() is not a valid pthread

Signed-off-by: default avatarChristopher Friedt <cfriedt@meta.com>
parent 3458527a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -174,13 +174,18 @@ int pthread_key_delete(pthread_key_t key)
int pthread_setspecific(pthread_key_t key, const void *value)
{
	pthread_key_obj *key_obj;
	struct posix_thread *thread = to_posix_thread(pthread_self());
	struct posix_thread *thread;
	struct pthread_key_data *key_data;
	pthread_thread_data *thread_spec_data;
	k_spinlock_key_t key_key;
	sys_snode_t *node_l;
	int retval = 0;

	thread = to_posix_thread(pthread_self());
	if (thread == NULL) {
		return EINVAL;
	}

	/* Traverse the list of keys set by the thread, looking for key.
	 * If the key is already in the list, re-assign its value.
	 * Else add the key to the thread's list.