Commit bb664f49 authored by Hendrik Brueckner's avatar Hendrik Brueckner Committed by David S. Miller

af_iucv: Change if condition in sendmsg() for more readability

Change the if condition to exit sendmsg() if the socket in not connected.
Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb2107be
...@@ -747,7 +747,12 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -747,7 +747,12 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
goto out; goto out;
} }
if (sk->sk_state == IUCV_CONNECTED) { /* Return if the socket is not in connected state */
if (sk->sk_state != IUCV_CONNECTED) {
err = -ENOTCONN;
goto out;
}
/* initialize defaults */ /* initialize defaults */
cmsg_done = 0; /* check for duplicate headers */ cmsg_done = 0; /* check for duplicate headers */
txmsg.class = 0; txmsg.class = 0;
...@@ -794,11 +799,10 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -794,11 +799,10 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
* this is fine for SOCK_SEQPACKET (unless we want to support * this is fine for SOCK_SEQPACKET (unless we want to support
* segmented records using the MSG_EOR flag), but * segmented records using the MSG_EOR flag), but
* for SOCK_STREAM we might want to improve it in future */ * for SOCK_STREAM we might want to improve it in future */
if (!(skb = sock_alloc_send_skb(sk, len, skb = sock_alloc_send_skb(sk, len, msg->msg_flags & MSG_DONTWAIT,
msg->msg_flags & MSG_DONTWAIT, &err);
&err))) if (!skb)
goto out; goto out;
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) { if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
err = -EFAULT; err = -EFAULT;
goto fail; goto fail;
...@@ -839,18 +843,13 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -839,18 +843,13 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
memcpy(appl_id, iucv->dst_name, 8); memcpy(appl_id, iucv->dst_name, 8);
pr_err("Application %s on z/VM guest %s" pr_err("Application %s on z/VM guest %s"
" exceeds message limit\n", " exceeds message limit\n",
user_id, appl_id); appl_id, user_id);
} }
skb_unlink(skb, &iucv->send_skb_q); skb_unlink(skb, &iucv->send_skb_q);
err = -EPIPE; err = -EPIPE;
goto fail; goto fail;
} }
} else {
err = -ENOTCONN;
goto out;
}
release_sock(sk); release_sock(sk);
return len; return len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment