diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 1c9d2685de3f3a940a0432f8ebc760f6ff326c02..b3ab3279568efe638b79cc3109396d9ee21b0fe0 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1294,10 +1294,8 @@ csum_copy_err:
 	}
 	unlock_sock_fast(sk, slow);
 
-	if (noblock)
-		return -EAGAIN;
-
-	/* starting over for a new packet */
+	/* starting over for a new packet, but check if we need to yield */
+	cond_resched();
 	msg->msg_flags &= ~MSG_TRUNC;
 	goto try_again;
 }
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index b01d23d2ec8aee52d74d811450bdd70420b66fc4..25f3babd59d469bf144e5175bf2f3616e1019aa3 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -494,10 +494,8 @@ csum_copy_err:
 	}
 	unlock_sock_fast(sk, slow);
 
-	if (noblock)
-		return -EAGAIN;
-
-	/* starting over for a new packet */
+	/* starting over for a new packet, but check if we need to yield */
+	cond_resched();
 	msg->msg_flags &= ~MSG_TRUNC;
 	goto try_again;
 }