From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C56AE49284 for ; Tue, 6 Feb 2024 21:27:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07F6668D085; Tue, 6 Feb 2024 23:27:00 +0200 (EET) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3CDE968C7C2 for ; Tue, 6 Feb 2024 23:26:54 +0200 (EET) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6da9c834646so4879361b3a.3 for ; Tue, 06 Feb 2024 13:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707254811; x=1707859611; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=fauEtMUBn+nhXG8cEhrkour2Lpukc5qN5jInZoewyRg=; b=DnK/EFlxJ+/ijmJK6FmxFK3MJ836Z9ArIfvAK5FPGR28Ej5jzHrabkKhg2y+2/1acH ETg8Gaw+GTAa2StfRAtjvd+bU/coSEeLhwZFGU8KNmDiKQr/bWJjMLvcxJqUElF7cKe6 YUPnJYRTfP9/bJOVA4NOkRmWZcqBGF7CLB7KPBCeND/P/ltOGew+0Jom42u5VXpDLDRf SposDvGyxpB2MD19is1rjaHSvlSFygBWZPU4jmOMEKfdVEz6PcpUQJZ45fSFWsBvvn1Z 4jpi4TjCzOryTuB5Q0YOaa8VgHT/HOSYWvWsolhKkIqkXAokirctiBrOyeMsmtZ7dvaq 4RIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707254811; x=1707859611; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fauEtMUBn+nhXG8cEhrkour2Lpukc5qN5jInZoewyRg=; b=kAXt35u854FA29Z7DmgKzOgKrPpwjlxACPPMzVI2yC3h3pM/dEzWdO8ASzB/s9f60T 06SdUIQTicxA92fjGMmpeGRXOJ89+AaoLRh+BTx/2UREBJdOS/1eOPlQwdrTyUdBqMCb Uwjd9l+/QdcZO6YIcS6PWoH3dpYnmlx5RXXs9zGJfsWlDtW8VEBJiePTKcUX6UevHSuV 30SsU+cglm7EXXX0UQ8g4MkE0ofTXbD+sCcJGCpKyRlPWhzKJZ24mXyGi7k6dkzR8nCK Jb/0RNHf6Wj+ZDR1V4Pl0YuJfMG8v6ySXQv7FFkYCRB+1Mnp6wXS+fw+RzZCgT3v/wn6 6ZJw== X-Gm-Message-State: AOJu0YyeS4ixIJqX0JUBzJBgqpefill9EHD37RxMgPJMsw+jEmaosPWs Quj0ZBEZPXuLQi9cdkFg2ODiens4PM9LKuArxs5FBVnTD1HBS7NaP2Qzmhh6 X-Google-Smtp-Source: AGHT+IFd+4gYFaHxL8kpmPbTDMrXcc2V+Jakeb1XL3LK+mD466Yv3Ag++1mGPMJ1wYKDPCr6t3H0jA== X-Received: by 2002:a05:6a00:4595:b0:6e0:4ea7:ed3f with SMTP id it21-20020a056a00459500b006e04ea7ed3fmr603573pfb.9.1707254811310; Tue, 06 Feb 2024 13:26:51 -0800 (PST) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id a24-20020a62d418000000b006db9604bf8csm2528577pfh.131.2024.02.06.13.26.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 13:26:50 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 6 Feb 2024 18:26:40 -0300 Message-ID: <20240206212640.9193-1-jamrial@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/nvdec: don't attempt to free NVDECContext->bitstream on simple decode_slice hwaccels 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: If FFHWAccel->end_frame() isn't called before FFHWAccel->uninit(), an attempt to free a stale pointer could take place. Signed-off-by: James Almer --- libavcodec/nvdec.c | 9 +++++++++ libavcodec/nvdec.h | 1 + libavcodec/nvdec_mjpeg.c | 2 +- libavcodec/nvdec_mpeg12.c | 4 ++-- libavcodec/nvdec_mpeg4.c | 2 +- libavcodec/nvdec_vc1.c | 4 ++-- libavcodec/nvdec_vp8.c | 2 +- libavcodec/nvdec_vp9.c | 2 +- 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index 27be644356..8a7f5c0dac 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -274,6 +274,15 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx) return 0; } +int ff_nvdec_simple_decode_uninit(AVCodecContext *avctx) +{ + NVDECContext *ctx = avctx->internal->hwaccel_priv_data; + + ctx->bitstream = NULL; + + return ff_nvdec_decode_uninit(avctx); +} + static void nvdec_free_dummy(struct AVHWFramesContext *ctx) { av_buffer_pool_uninit(&ctx->pool); diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h index 353e95bf42..83bc1de84c 100644 --- a/libavcodec/nvdec.h +++ b/libavcodec/nvdec.h @@ -73,6 +73,7 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx); int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame); int ff_nvdec_start_frame_sep_ref(AVCodecContext *avctx, AVFrame *frame, int has_sep_ref); int ff_nvdec_end_frame(AVCodecContext *avctx); +int ff_nvdec_simple_decode_uninit(AVCodecContext *avctx); int ff_nvdec_simple_end_frame(AVCodecContext *avctx); int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size); diff --git a/libavcodec/nvdec_mjpeg.c b/libavcodec/nvdec_mjpeg.c index 850634bf1a..adef21b0f7 100644 --- a/libavcodec/nvdec_mjpeg.c +++ b/libavcodec/nvdec_mjpeg.c @@ -80,6 +80,6 @@ const FFHWAccel ff_mjpeg_nvdec_hwaccel = { .decode_slice = nvdec_mjpeg_decode_slice, .frame_params = nvdec_mjpeg_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c index a4603c7ea7..5d100a46ba 100644 --- a/libavcodec/nvdec_mpeg12.c +++ b/libavcodec/nvdec_mpeg12.c @@ -110,7 +110,7 @@ const FFHWAccel ff_mpeg2_nvdec_hwaccel = { .decode_slice = ff_nvdec_simple_decode_slice, .frame_params = nvdec_mpeg12_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; #endif @@ -126,7 +126,7 @@ const FFHWAccel ff_mpeg1_nvdec_hwaccel = { .decode_slice = ff_nvdec_simple_decode_slice, .frame_params = nvdec_mpeg12_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; #endif diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index 20a0499437..5a50f7d77f 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -120,6 +120,6 @@ const FFHWAccel ff_mpeg4_nvdec_hwaccel = { .decode_slice = nvdec_mpeg4_decode_slice, .frame_params = nvdec_mpeg4_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c index 5096d784df..e9ab16c63d 100644 --- a/libavcodec/nvdec_vc1.c +++ b/libavcodec/nvdec_vc1.c @@ -124,7 +124,7 @@ const FFHWAccel ff_vc1_nvdec_hwaccel = { .decode_slice = ff_nvdec_simple_decode_slice, .frame_params = nvdec_vc1_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; @@ -139,7 +139,7 @@ const FFHWAccel ff_wmv3_nvdec_hwaccel = { .decode_slice = ff_nvdec_simple_decode_slice, .frame_params = nvdec_vc1_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; #endif diff --git a/libavcodec/nvdec_vp8.c b/libavcodec/nvdec_vp8.c index ff3b3f259c..bbea6f1577 100644 --- a/libavcodec/nvdec_vp8.c +++ b/libavcodec/nvdec_vp8.c @@ -101,6 +101,6 @@ const FFHWAccel ff_vp8_nvdec_hwaccel = { .decode_slice = ff_nvdec_simple_decode_slice, .frame_params = nvdec_vp8_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; diff --git a/libavcodec/nvdec_vp9.c b/libavcodec/nvdec_vp9.c index e196391c6d..69b12657b6 100644 --- a/libavcodec/nvdec_vp9.c +++ b/libavcodec/nvdec_vp9.c @@ -180,6 +180,6 @@ const FFHWAccel ff_vp9_nvdec_hwaccel = { .decode_slice = ff_nvdec_simple_decode_slice, .frame_params = nvdec_vp9_frame_params, .init = ff_nvdec_decode_init, - .uninit = ff_nvdec_decode_uninit, + .uninit = ff_nvdec_simple_decode_uninit, .priv_data_size = sizeof(NVDECContext), }; -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".