From patchwork Tue Jun 28 11:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wujian(Chin)" X-Patchwork-Id: 36494 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp2581365pzh; Tue, 28 Jun 2022 04:15:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vU9zsZYmInS5WB/lRDp6MRa6rB9v+aNwEn/9+vUVjewNn/SI4QOptI/MSvyhFJMTZ9qqG9 X-Received: by 2002:a05:6402:5c8:b0:433:545f:a811 with SMTP id n8-20020a05640205c800b00433545fa811mr22502138edx.101.1656414927365; Tue, 28 Jun 2022 04:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656414927; cv=none; d=google.com; s=arc-20160816; b=pMZkyO4XsVuQRe8oiLxHRV1qE+0caFrHE02B3ezOuMh2D7ZRhbFjVVzA83Ccu5h1An DAdKwtk9WXK8SpxWn13uZ1Eg4EUc/6IV2Dt8jrHm8hvMeak2stFOWv7TZvxZuPyNUX9S 6nCTC9foaHVJfofMykSKuF3WghldOfMiLwpt93afUjqii6rWJywDU9SPS8S976V5ESen I7l9x47bgTcC9c37zT8jg2+Kyyz1TgcfzJYq11VjtIfullo70wv1n1noMbh4EIilK33J PlH0mfjdPnj5wEX18xuQ8RtqoBWN3HaY8JwaVC2GSV54CXPr5mF/eaUtiWkaH/u+TXQC oMDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:content-language :accept-language:message-id:date:thread-index:thread-topic:to:from :delivered-to; bh=2ZpEQDZd6UuJzHm+rt38IWBB8ksAJU3sFU97mSzL/tA=; b=m+KsVuWwy/kzHfElA0JnrXy8CXMvKYd1HSBANWi5MbYg2T03sZy003bIlpnpk5ZsS4 BWyh/rNWL7EJeYrZzpPBceigyKcfy9cjuY3wgPiAogM1dfJzXW/NMIYHViFNa9wmzQTb nLt1vWQRBSRYtMmEe/JWJT+0cRpH45XUsAPinJtoXL7L8LI8W3iGGC68Wk5CGUK0u6qF /fYS9DhV8IWqtaQZNQCTJUBdN+loWyMJlzoidTPGaElciSjiI10owa1X0nBJ4u08uytj ehggrn23O2l2wIU2O9owcwlW2LELrSVzHeE0gJtV5sQF/HF5VE3dsdNxtr+YaQ9jH+M0 J4cA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a11-20020a170906190b00b006e82f2c77cfsi13807471eje.199.2022.06.28.04.15.26; Tue, 28 Jun 2022 04:15:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EBA0868B913; Tue, 28 Jun 2022 14:15:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 64A6268B6EA for ; Tue, 28 Jun 2022 14:15:16 +0300 (EEST) Received: from kwepemi100013.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LXMQp2lKKzcg36; Tue, 28 Jun 2022 19:13:22 +0800 (CST) Received: from kwepemi500014.china.huawei.com (7.221.188.232) by kwepemi100013.china.huawei.com (7.221.188.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 19:15:12 +0800 Received: from kwepemi500014.china.huawei.com ([7.221.188.232]) by kwepemi500014.china.huawei.com ([7.221.188.232]) with mapi id 15.01.2375.024; Tue, 28 Jun 2022 19:15:12 +0800 From: "Wujian(Chin)" To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH] avcodec/v4l2_m2m: Check if the file descriptor is valid before closing Thread-Index: AdiK4FSIEOOxvdp0RCaxqwBO7BBMyA== Date: Tue, 28 Jun 2022 11:15:12 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.136.102.143] MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m: Check if the file descriptor is valid before closing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Patchwork , FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +qZcdptHEsy5 Fixes ticket #9507. Signed-off-by: wujian_nanjing --- libavcodec/v4l2_m2m.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c index 51932ba..9849360 100644 --- a/libavcodec/v4l2_m2m.c +++ b/libavcodec/v4l2_m2m.c @@ -251,7 +251,8 @@ 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);