diff --git a/libavformat/utils.c b/libavformat/utils.c
index 4f3529aff4a80fd866e0d4853d6f2c8e1cc47e85..2a8fac1e99433cfaedb0842dd76e611b58e0d5ee 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1409,18 +1409,12 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
     AVStream *st;
 
     if (!genpts) {
-        while (1) {
-            ret = s->packet_buffer ?
-                read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt) :
-                read_frame_internal(s, pkt);
-            if (ret < 0) {
-                if (ret == AVERROR(EAGAIN))
-                    continue;
-                else
-                    return ret;
-            }
-            goto return_packet;
-        }
+        ret = s->packet_buffer ?
+            read_from_packet_buffer(&s->packet_buffer, &s->packet_buffer_end, pkt) :
+            read_frame_internal(s, pkt);
+        if (ret < 0)
+            return ret;
+        goto return_packet;
     }
 
     for (;;) {