diff mbox series

[FFmpeg-devel,1/2] libavdevice: Fix a potential deadlock issue on the lock ctx->frame_lock in function get_audio_config

Message ID 20210826132657.91732-1-cyeaa@connect.ust.hk
State New
Headers show
Series [FFmpeg-devel,1/2] libavdevice: Fix a potential deadlock issue on the lock ctx->frame_lock in function get_audio_config | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

YE Chengfeng Aug. 26, 2021, 1:26 p.m. UTC
The problem here is that the lock ctx->frame_lock will become an unreleased lock if the program returns at line 697, line 735 and line744

Cc: cyeaa@connect.ust.hk
Bug tracker link: https://trac.ffmpeg.org/ticket/9385\#ticket

Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
---
 libavdevice/avfoundation.m | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 1d108417be..0953a8b11e 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -694,6 +694,7 @@  static int get_audio_config(AVFormatContext *s)
 
     if (!basic_desc) {
         av_log(s, AV_LOG_ERROR, "audio format not available\n");
+		unlock_frames(ctx);
         return 1;
     }
 
@@ -732,6 +733,7 @@  static int get_audio_config(AVFormatContext *s)
         stream->codecpar->codec_id = ctx->audio_be ? AV_CODEC_ID_PCM_S32BE : AV_CODEC_ID_PCM_S32LE;
     } else {
         av_log(s, AV_LOG_ERROR, "audio format is not supported\n");
+		unlock_frames(ctx);
         return 1;
     }
 
@@ -741,6 +743,7 @@  static int get_audio_config(AVFormatContext *s)
         ctx->audio_buffer             = av_malloc(ctx->audio_buffer_size);
         if (!ctx->audio_buffer) {
             av_log(s, AV_LOG_ERROR, "error allocating audio buffer\n");
+			unlock_frames(ctx);
             return 1;
         }
     }