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

posix: pthread_getspecific: fix for coverity issue cid 334909



* remove unneeded line of code that duplicated the first part
  of the SYS_SLIST_FOR_EACH_NODE() expansion.
* return NULL if pthread_self() is not a valid pthread

Signed-off-by: default avatarChristopher Friedt <cfriedt@meta.com>
parent c48d61a4
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -248,12 +248,17 @@ out:
void *pthread_getspecific(pthread_key_t key)
{
	pthread_key_obj *key_obj;
	struct posix_thread *thread = to_posix_thread(pthread_self());
	struct posix_thread *thread;
	pthread_thread_data *thread_spec_data;
	void *value = NULL;
	sys_snode_t *node_l;
	k_spinlock_key_t key_key;

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

	key_key = k_spin_lock(&pthread_key_lock);

	key_obj = get_posix_key(key);
@@ -262,8 +267,6 @@ void *pthread_getspecific(pthread_key_t key)
		return NULL;
	}

	node_l = sys_slist_peek_head(&(thread->key_list));

	/* Traverse the list of keys set by the thread, looking for key */

	SYS_SLIST_FOR_EACH_NODE(&(thread->key_list), node_l) {