@@ -191,31 +191,32 @@ int ecryptfs_send_miscdev(char *data, size_t data_size,
191
191
struct ecryptfs_msg_ctx * msg_ctx , u8 msg_type ,
192
192
u16 msg_flags , struct ecryptfs_daemon * daemon )
193
193
{
194
- int rc = 0 ;
194
+ struct ecryptfs_message * msg ;
195
195
196
- mutex_lock (& msg_ctx -> mux );
197
- msg_ctx -> msg = kmalloc ((sizeof (* msg_ctx -> msg ) + data_size ),
198
- GFP_KERNEL );
199
- if (!msg_ctx -> msg ) {
200
- rc = - ENOMEM ;
196
+ msg = kmalloc ((sizeof (* msg ) + data_size ), GFP_KERNEL );
197
+ if (!msg ) {
201
198
printk (KERN_ERR "%s: Out of memory whilst attempting "
202
199
"to kmalloc(%zd, GFP_KERNEL)\n" , __func__ ,
203
- (sizeof (* msg_ctx -> msg ) + data_size ));
204
- goto out_unlock ;
200
+ (sizeof (* msg ) + data_size ));
201
+ return - ENOMEM ;
205
202
}
203
+
204
+ mutex_lock (& msg_ctx -> mux );
205
+ msg_ctx -> msg = msg ;
206
206
msg_ctx -> msg -> index = msg_ctx -> index ;
207
207
msg_ctx -> msg -> data_len = data_size ;
208
208
msg_ctx -> type = msg_type ;
209
209
memcpy (msg_ctx -> msg -> data , data , data_size );
210
210
msg_ctx -> msg_size = (sizeof (* msg_ctx -> msg ) + data_size );
211
- mutex_lock (& daemon -> mux );
212
211
list_add_tail (& msg_ctx -> daemon_out_list , & daemon -> msg_ctx_out_queue );
212
+ mutex_unlock (& msg_ctx -> mux );
213
+
214
+ mutex_lock (& daemon -> mux );
213
215
daemon -> num_queued_msg_ctx ++ ;
214
216
wake_up_interruptible (& daemon -> wait );
215
217
mutex_unlock (& daemon -> mux );
216
- out_unlock :
217
- mutex_unlock (& msg_ctx -> mux );
218
- return rc ;
218
+
219
+ return 0 ;
219
220
}
220
221
221
222
/*
0 commit comments