@@ -488,6 +488,7 @@ rxrpc_new_client_call_for_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg,
488488int rxrpc_do_sendmsg (struct rxrpc_sock * rx , struct msghdr * msg , size_t len )
489489 __releases (& rx - > sk .sk_lock .slock )
490490{
491+ enum rxrpc_call_state state ;
491492 enum rxrpc_command cmd ;
492493 struct rxrpc_call * call ;
493494 unsigned long user_call_ID = 0 ;
@@ -526,13 +527,17 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
526527 return PTR_ERR (call );
527528 /* ... and we have the call lock. */
528529 } else {
529- ret = - EBUSY ;
530- if (call -> state == RXRPC_CALL_UNINITIALISED ||
531- call -> state == RXRPC_CALL_CLIENT_AWAIT_CONN ||
532- call -> state == RXRPC_CALL_SERVER_PREALLOC ||
533- call -> state == RXRPC_CALL_SERVER_SECURING ||
534- call -> state == RXRPC_CALL_SERVER_ACCEPTING )
530+ switch (READ_ONCE (call -> state )) {
531+ case RXRPC_CALL_UNINITIALISED :
532+ case RXRPC_CALL_CLIENT_AWAIT_CONN :
533+ case RXRPC_CALL_SERVER_PREALLOC :
534+ case RXRPC_CALL_SERVER_SECURING :
535+ case RXRPC_CALL_SERVER_ACCEPTING :
536+ ret = - EBUSY ;
535537 goto error_release_sock ;
538+ default :
539+ break ;
540+ }
536541
537542 ret = mutex_lock_interruptible (& call -> user_mutex );
538543 release_sock (& rx -> sk );
@@ -542,10 +547,11 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
542547 }
543548 }
544549
550+ state = READ_ONCE (call -> state );
545551 _debug ("CALL %d USR %lx ST %d on CONN %p" ,
546- call -> debug_id , call -> user_call_ID , call -> state , call -> conn );
552+ call -> debug_id , call -> user_call_ID , state , call -> conn );
547553
548- if (call -> state >= RXRPC_CALL_COMPLETE ) {
554+ if (state >= RXRPC_CALL_COMPLETE ) {
549555 /* it's too late for this call */
550556 ret = - ESHUTDOWN ;
551557 } else if (cmd == RXRPC_CMD_SEND_ABORT ) {
@@ -555,12 +561,12 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
555561 } else if (cmd != RXRPC_CMD_SEND_DATA ) {
556562 ret = - EINVAL ;
557563 } else if (rxrpc_is_client_call (call ) &&
558- call -> state != RXRPC_CALL_CLIENT_SEND_REQUEST ) {
564+ state != RXRPC_CALL_CLIENT_SEND_REQUEST ) {
559565 /* request phase complete for this client call */
560566 ret = - EPROTO ;
561567 } else if (rxrpc_is_service_call (call ) &&
562- call -> state != RXRPC_CALL_SERVER_ACK_REQUEST &&
563- call -> state != RXRPC_CALL_SERVER_SEND_REPLY ) {
568+ state != RXRPC_CALL_SERVER_ACK_REQUEST &&
569+ state != RXRPC_CALL_SERVER_SEND_REPLY ) {
564570 /* Reply phase not begun or not complete for service call. */
565571 ret = - EPROTO ;
566572 } else {
@@ -605,14 +611,20 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
605611 _debug ("CALL %d USR %lx ST %d on CONN %p" ,
606612 call -> debug_id , call -> user_call_ID , call -> state , call -> conn );
607613
608- if (call -> state >= RXRPC_CALL_COMPLETE ) {
609- ret = - ESHUTDOWN ; /* it's too late for this call */
610- } else if (call -> state != RXRPC_CALL_CLIENT_SEND_REQUEST &&
611- call -> state != RXRPC_CALL_SERVER_ACK_REQUEST &&
612- call -> state != RXRPC_CALL_SERVER_SEND_REPLY ) {
613- ret = - EPROTO ; /* request phase complete for this client call */
614- } else {
614+ switch (READ_ONCE (call -> state )) {
615+ case RXRPC_CALL_CLIENT_SEND_REQUEST :
616+ case RXRPC_CALL_SERVER_ACK_REQUEST :
617+ case RXRPC_CALL_SERVER_SEND_REPLY :
615618 ret = rxrpc_send_data (rxrpc_sk (sock -> sk ), call , msg , len );
619+ break ;
620+ case RXRPC_CALL_COMPLETE :
621+ /* It's too late for this call */
622+ ret = - ESHUTDOWN ;
623+ break ;
624+ default :
625+ /* Request phase complete for this client call */
626+ ret = - EPROTO ;
627+ break ;
616628 }
617629
618630 mutex_unlock (& call -> user_mutex );
0 commit comments