diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index d92e2996fd1d72339e2c84f7a79023b2bcfc81c3..3453b4d3e7e13b3012ce6ec2a660f6b0ff5e2763 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -337,7 +337,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
     }
 
     if ((ret = create_subcc_streams(avctx)) < 0)
-        FAIL(ret);
+        goto end;
 
     if (!(lavfi->decoded_frame = av_frame_alloc()))
         FAIL(AVERROR(ENOMEM));