From patchwork Wed Sep 19 02:01:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 10399 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp147845jap; Tue, 18 Sep 2018 19:01:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaUzz70OSs+Pl9rYTKup3+4nBAsbD1iogd21/3QhHZ7kY5U+uDyjzssGGALbnXWgkI+wpo0 X-Received: by 2002:adf:f984:: with SMTP id f4-v6mr26637954wrr.105.1537322497166; Tue, 18 Sep 2018 19:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537322497; cv=none; d=google.com; s=arc-20160816; b=VZ8roAbvzj+wu4zHeREyAOeOW85/HX8UF1kmF5vnNHguUkAORBdziUaIqEAe8phq0n Dp93h1wNeaMQCJjFRbT0Au+n6lFk9dofse0tF4nsEuT6+73YY951mx74NP92uiyEx2FB 3HZpL5AB29adgczgxWpf9C7M+Haa7e4f30ghqFICVjFX1kfn2bPGAInJv9mvmUDyCVnn qzuIJGEyqUEZzprc1qbFhwSOXLupXCWZEn7c6zeInVAxjMUf49aMr2DBYfnhz526lbaz 8xiLPvvbt07hJDEobrtnfHJ7usQzBPTFfwky6Z/EJLjDHJtbk+6S/mDYkF/b4HbO7kVB 0lQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to; bh=S6D4js5Ibx21S/5pzjBiInxsAURuqkB1t5N14gScxLg=; b=unO+CqyGdzjGT4D9tPlRVs5sAUL2z6m6pl2wxE88Vm1nhd768OM9IXHWfbSwQ6GFwv REi+eL40ME13/Gbt6/KoGoBjol1PloLDDmyTyscnigpVtCG3PIwFNwhOjj3XD3HNvHBF WDT+I/Q78vWAVFi2YukiEUBNzaw33XAeoeXhG/oYrb6oacalzZfifDNTtHentAMDiwxc fypNuSHYB/K1iM+T7R7HE8Og9RdiY94SesulVFTQw6/U/qoCkEgZHaxZySTSP25oH3Bj DLI00FaT55lU8y8towbVmDOysCl56DbM0G0+LHUENGKtJ3QT7GxPm7BFMf7a+hqE3vpy +fzw== 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j126-v6si4513887wma.192.2018.09.18.19.01.36; Tue, 18 Sep 2018 19:01:37 -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=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D829A68A52A; Wed, 19 Sep 2018 05:01:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A491A689EFE for ; Wed, 19 Sep 2018 05:01:14 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2018 19:01:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,392,1531810800"; d="scan'208";a="74131637" Received: from kubernetes-master.sh.intel.com ([10.239.159.161]) by orsmga007.jf.intel.com with ESMTP; 18 Sep 2018 19:01:24 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Sep 2018 10:01:23 +0800 Message-Id: <20180919020123.14736-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH V2] avcodec/vaapi:free slice_buffers when decoding failed X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If vaEndPicture failed in ff_vaapi_decode_issue, free the pic->slice_buffer. Fix the memory leak issue in ticket #7385 [V2] unit the return paths under the "exit" tag at the end of the function. Signed-off-by: Linjie Fu --- libavcodec/vaapi_decode.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index d0a6b5817d..3ee9c6be51 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -152,7 +152,7 @@ int ff_vaapi_decode_issue(AVCodecContext *avctx, { VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data; VAStatus vas; - int err; + int err = 0; av_log(avctx, AV_LOG_DEBUG, "Decode to surface %#x.\n", pic->output_surface); @@ -200,12 +200,7 @@ int ff_vaapi_decode_issue(AVCodecContext *avctx, AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS) ff_vaapi_decode_destroy_buffers(avctx, pic); - pic->nb_param_buffers = 0; - pic->nb_slices = 0; - pic->slices_allocated = 0; - av_freep(&pic->slice_buffers); - - return 0; + goto exit; fail_with_picture: vas = vaEndPicture(ctx->hwctx->display, ctx->va_context); @@ -216,6 +211,12 @@ fail_with_picture: fail: ff_vaapi_decode_destroy_buffers(avctx, pic); fail_at_end: +exit: + pic->nb_param_buffers = 0; + pic->nb_slices = 0; + pic->slices_allocated = 0; + av_freep(&pic->slice_buffers); + return err; }