diff mbox series

[FFmpeg-devel] 答复: [PATCH] avcodec/v4l2_m2m: close the invalid file descriptor -1 in function v4l2_m2m_destroy_context

Message ID bb49a8cada644e1c95624ccf9cb19b9a@huawei.com
State New
Headers show
Series [FFmpeg-devel] 答复: [PATCH] avcodec/v4l2_m2m: close the invalid file descriptor -1 in function v4l2_m2m_destroy_context | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch
andriy/configure_armv7_RPi4 warning Failed to apply patch

Commit Message

Wujian(Chin) June 25, 2022, 3:04 a.m. UTC
Hi:
Please review it.
Thks!

-----邮件原件-----
发件人: Wujian(Chin) 
发送时间: 2022年6月15日 19:15
收件人: 'ffmpeg-devel@ffmpeg.org' <ffmpeg-devel@ffmpeg.org>
主题: [PATCH] avcodec/v4l2_m2m: close the invalid file descriptor -1 in function v4l2_m2m_destroy_context

Signed-off-by: wujian_nanjing <wujian2@huawei.com>
---
 libavcodec/v4l2_m2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--
2.7.4

Comments

Andriy Gelman June 25, 2022, 10:05 p.m. UTC | #1
Hi,

On Sat, 25. Jun 03:04, Wujian(Chin) wrote:
> Hi:
> Please review it.
> Thks!
> 
> -----邮件原件-----
> 发件人: Wujian(Chin) 
> 发送时间: 2022年6月15日 19:15
> 收件人: 'ffmpeg-devel@ffmpeg.org' <ffmpeg-devel@ffmpeg.org>
> 主题: [PATCH] avcodec/v4l2_m2m: close the invalid file descriptor -1 in function v4l2_m2m_destroy_context

Maybe this title would be better?
avcodec/v4l2_m2m: Check if the file descriptor is valid before closing

Mention the trac ticket in the commit message please.

> Signed-off-by: wujian_nanjing <wujian2@huawei.com>

Remove the _?

> ---
>  libavcodec/v4l2_m2m.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c index 51932ba..4427b48 100644
> --- a/libavcodec/v4l2_m2m.c
> +++ b/libavcodec/v4l2_m2m.c
> @@ -251,7 +251,9 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context)
>      ff_v4l2_context_release(&s->capture);
>      sem_destroy(&s->refsync);
>  
> -    close(s->fd);
> +    if (s->fd >= 0)
> +        close(s->fd);
> +

The patch change looks fine, but it doesn't apply.

Thanks,
diff mbox series

Patch

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c index 51932ba..4427b48 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -251,7 +251,9 @@  static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context)
     ff_v4l2_context_release(&s->capture);
     sem_destroy(&s->refsync);
 
-    close(s->fd);
+    if (s->fd >= 0)
+        close(s->fd);
+
     av_frame_unref(s->frame);
     av_frame_free(&s->frame);
     av_packet_unref(&s->buf_pkt);