Lines Matching +full:non +full:- +full:zero

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2004-2008 International Business Machines Corp.
33 * on the context. Sets the msg_ctx task to current. Returns zero on
34 * success; non-zero on error or upon failure to acquire a free
49 rc = -ENOMEM; in ecryptfs_acquire_free_msg_ctx()
54 if (mutex_trylock(&(*msg_ctx)->mux)) { in ecryptfs_acquire_free_msg_ctx()
55 (*msg_ctx)->task = current; in ecryptfs_acquire_free_msg_ctx()
60 rc = -ENOMEM; in ecryptfs_acquire_free_msg_ctx()
73 list_move(&msg_ctx->node, &ecryptfs_msg_ctx_alloc_list); in ecryptfs_msg_ctx_free_to_alloc()
74 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_PENDING; in ecryptfs_msg_ctx_free_to_alloc()
75 msg_ctx->counter = ++ecryptfs_msg_counter; in ecryptfs_msg_ctx_free_to_alloc()
86 list_move(&(msg_ctx->node), &ecryptfs_msg_ctx_free_list); in ecryptfs_msg_ctx_alloc_to_free()
87 kfree(msg_ctx->msg); in ecryptfs_msg_ctx_alloc_to_free()
88 msg_ctx->msg = NULL; in ecryptfs_msg_ctx_alloc_to_free()
89 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_FREE; in ecryptfs_msg_ctx_alloc_to_free()
94 * @daemon: If return value is zero, points to the desired daemon pointer
100 * Returns zero if the user id exists in the list; non-zero otherwise.
109 if (uid_eq((*daemon)->file->f_cred->euid, current_euid())) { in ecryptfs_find_daemon_by_euid()
114 rc = -EINVAL; in ecryptfs_find_daemon_by_euid()
120 * ecryptfs_spawn_daemon - Create and initialize a new daemon struct
127 * Returns zero on success; non-zero otherwise
136 rc = -ENOMEM; in ecryptfs_spawn_daemon()
139 (*daemon)->file = file; in ecryptfs_spawn_daemon()
140 mutex_init(&(*daemon)->mux); in ecryptfs_spawn_daemon()
141 INIT_LIST_HEAD(&(*daemon)->msg_ctx_out_queue); in ecryptfs_spawn_daemon()
142 init_waitqueue_head(&(*daemon)->wait); in ecryptfs_spawn_daemon()
143 (*daemon)->num_queued_msg_ctx = 0; in ecryptfs_spawn_daemon()
144 hlist_add_head(&(*daemon)->euid_chain, in ecryptfs_spawn_daemon()
151 * ecryptfs_exorcise_daemon - Destroy the daemon struct
161 mutex_lock(&daemon->mux); in ecryptfs_exorcise_daemon()
162 if ((daemon->flags & ECRYPTFS_DAEMON_IN_READ) in ecryptfs_exorcise_daemon()
163 || (daemon->flags & ECRYPTFS_DAEMON_IN_POLL)) { in ecryptfs_exorcise_daemon()
164 rc = -EBUSY; in ecryptfs_exorcise_daemon()
165 mutex_unlock(&daemon->mux); in ecryptfs_exorcise_daemon()
169 &daemon->msg_ctx_out_queue, daemon_out_list) { in ecryptfs_exorcise_daemon()
170 list_del(&msg_ctx->daemon_out_list); in ecryptfs_exorcise_daemon()
171 daemon->num_queued_msg_ctx--; in ecryptfs_exorcise_daemon()
176 hlist_del(&daemon->euid_chain); in ecryptfs_exorcise_daemon()
177 mutex_unlock(&daemon->mux); in ecryptfs_exorcise_daemon()
187 * msg->data_len and free the memory
199 * that msg_ctx->state == ECRYPTFS_MSG_CTX_STATE_DONE, and then
200 * proceed to read off and process the response message. Returns zero
201 * upon delivery to desired context element; non-zero upon delivery
204 * Returns zero on success; non-zero otherwise
213 if (msg->index >= ecryptfs_message_buf_len) { in ecryptfs_process_response()
214 rc = -EINVAL; in ecryptfs_process_response()
217 "allowable is [%d]\n", __func__, msg->index, in ecryptfs_process_response()
218 (ecryptfs_message_buf_len - 1)); in ecryptfs_process_response()
221 msg_ctx = &ecryptfs_msg_ctx_arr[msg->index]; in ecryptfs_process_response()
222 mutex_lock(&msg_ctx->mux); in ecryptfs_process_response()
223 if (msg_ctx->state != ECRYPTFS_MSG_CTX_STATE_PENDING) { in ecryptfs_process_response()
224 rc = -EINVAL; in ecryptfs_process_response()
228 } else if (msg_ctx->counter != seq) { in ecryptfs_process_response()
229 rc = -EINVAL; in ecryptfs_process_response()
232 msg_ctx->counter, seq); in ecryptfs_process_response()
235 msg_size = (sizeof(*msg) + msg->data_len); in ecryptfs_process_response()
236 msg_ctx->msg = kmemdup(msg, msg_size, GFP_KERNEL); in ecryptfs_process_response()
237 if (!msg_ctx->msg) { in ecryptfs_process_response()
238 rc = -ENOMEM; in ecryptfs_process_response()
241 msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_DONE; in ecryptfs_process_response()
242 wake_up_process(msg_ctx->task); in ecryptfs_process_response()
245 mutex_unlock(&msg_ctx->mux); in ecryptfs_process_response()
259 * Returns zero on success; non-zero otherwise
270 rc = -ENOTCONN; in ecryptfs_send_message_locked()
282 mutex_unlock(&(*msg_ctx)->mux); in ecryptfs_send_message_locked()
301 * Returns zero on success; non-zero otherwise
321 * of time exceeds ecryptfs_message_wait_timeout. If zero is
323 * non-zero value is returned upon failure to receive a message or an
335 mutex_lock(&msg_ctx->mux); in ecryptfs_wait_for_response()
336 if (msg_ctx->state != ECRYPTFS_MSG_CTX_STATE_DONE) { in ecryptfs_wait_for_response()
338 mutex_unlock(&msg_ctx->mux); in ecryptfs_wait_for_response()
342 rc = -ENOMSG; in ecryptfs_wait_for_response()
344 *msg = msg_ctx->msg; in ecryptfs_wait_for_response()
345 msg_ctx->msg = NULL; in ecryptfs_wait_for_response()
348 mutex_unlock(&msg_ctx->mux); in ecryptfs_wait_for_response()
372 rc = -ENOMEM; in ecryptfs_init_messaging()
384 rc = -ENOMEM; in ecryptfs_init_messaging()