From patchwork Sat Aug 6 17:28:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37162 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a9:b0:8d:7f3b:94fc with SMTP id q41csp896031pzg; Sat, 6 Aug 2022 10:28:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR5EHKm45ggAmynJ4wSuMWmd2Gb8xdffGFQeL0CzqNBJJ/X/AolrdT+vqzGjZCEnb8XZRlHR X-Received: by 2002:a05:6402:400e:b0:440:253e:961a with SMTP id d14-20020a056402400e00b00440253e961amr6749876eda.285.1659806911865; Sat, 06 Aug 2022 10:28:31 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u6-20020aa7d0c6000000b0043a6ddb2941si2093841edo.253.2022.08.06.10.28.31; Sat, 06 Aug 2022 10:28:31 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=oOaYEBQ1; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 65DE768B658; Sat, 6 Aug 2022 20:28:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2069.outbound.protection.outlook.com [40.92.90.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7311F68AD28 for ; Sat, 6 Aug 2022 20:28:20 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SXt02RFKfriRf8HB91HbACxTExOuLiHglliymoS55i0+4zMUY45kFR+HvCqm1DZAhrjYYsIwwObzE3SzAKLINyvVxKecrA90yxYh7nCfyxFcd2zboJ9foNzKJIg0mRHKKcRJz+KwnHxwXIRqaSqX25HGWtQlkY427a3b1H2vCaKnYw0W8I4Xl8yqfnd+M43e/FQW2t6WQftP05LTjDIPcecNLPiiEbEsUwBc6qnDdTjMgHdTHYKjTNkp1IU0qGj5sJvr/0Km8i6itg5g6PjEPMavuh1QYyOyrW5fpgrsGrdGBnWAcsdashaSHuIvH+J3NEWxdpMV7/6BIthAZHJOIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5oEGnzPgWoNkInHiBMndreY7/h7EoaApqcCAeNEa3os=; b=jF/sXCoUpzHCD4GqYiA8+yoKBVJ+XdnLiDYap9Fj8Ntm9gILn5HMIQVac+cu+wk1FY6QFTIfWx0jqUyniZAuL22WdTUzDvj3R1XG9VKIok7zU+FFEvT2GX6fJNKquy24YohlnqmrEYWbXDRI6w9SX0aIrUD/MMilTR3/Y4qPwk8RPRjITQ5QU4OADbzrAhNPRrGTjrTG6E6Ui1Kn70SaXzIITrrqb8nFDPwKeIqpUldJVTERrBbHsZkQ5Ijd4U1zme7NRx4pHrPv7dothavCGy3wgGlHcNVOw6ZreHZldSlJQf47VlO6lrXfW/MJoG5bYd5nhiXgZQx3oz0roWxm7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5oEGnzPgWoNkInHiBMndreY7/h7EoaApqcCAeNEa3os=; b=oOaYEBQ1IQkXbKUEQj/XHyOMPuLImVbQ1n0YSwS5SkcKXJ1vIxyFjShfImTICeuhW7rbcFSlbhtg44lwCLF2LkBZNly3/YbuQU6uIjs+DOg2yXf9EbXSnB3FU4vuCQFw602q+PzY+zxKKY9rpL6TIdr+gG4r0rI/DuVOsYF/OuSDlLsO6wv9shh4rNVWcNjT91VDX7IHTnuanFjT8ZKDKfIx0ZtkqAIE+VbMy19hyPBA6jiTaE0z9XlO/IE92SKl3PZed/ZJO52mK926T6g4WAL4CqsU6Cw1fu9I/mxecrfeiZzFoC2VDwBpS7+qsi56I1Mlo/Gaa8cgVH6d/9iang== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by VI1PR01MB4400.eurprd01.prod.exchangelabs.com (2603:10a6:803:6e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Sat, 6 Aug 2022 17:28:18 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46%11]) with mapi id 15.20.5504.016; Sat, 6 Aug 2022 17:28:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Aug 2022 19:28:08 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [WA01cySsEGZLxB2bpGaYKFQsEFxvpKl6] X-ClientProxiedBy: AS9PR05CA0009.eurprd05.prod.outlook.com (2603:10a6:20b:488::10) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220806172810.294485-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8c3726d-1781-4652-1a46-08da77d10d36 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/ULkXTfjO87bVJ5/VVNh3R154/YYEY2hcVZ27eeUCXex3FJiK2HECbGhsJufi03wVzzr2v5arheBobxmuCzjuABlUNROMT+XoSAoE1/txWMXk3MlC8mn5p17Rn/1ODkFuCN1pnzHV9USDGYYAAFHEYl6d0b4evYfTYZOFAh7wuqM+wR69ZD2F1l1fk1RhTkg4v7dY6Hqi2+5QmHQBtIstYubc2OtyaIQF3Lg863f1wnone3u4g86USB48mzoUngciZyGQhIxMpqy8oS10BGkjcbnZkXlwjUPkRn7iV0r74FdGSXMZss12Cmg92ROkeQMvxSnfBZ17p2ON609hgLiyIgl0ofMmUvRg8skhBcPRDtmH5BhQcXMjXrZaWplxAO/HMca5YZeYHpXtv2QROw+Cp9CVX1C4Don7TsWhMu1NlPCKZeA+uMDnS9HFOsAGUNQMqoDp5/XE/wumY8VNlOFgbE0gYOSka5VF+R7l+GEQrE7XI75cFAis/CZTwBBeSs/ntX298AGLVUxU44qOq0iaWHcP/hcWGVAW0vgsXZQjCt2kZNyaKzcGH4rrh3/Fa32+5bitVeohvV71COfj8oYoFGZyb/Wo1LnpVylocs9UxztiZVqa65C+mBsWfcXpHK1RHE4diEgWXo+RHeZ1dPGdCFvHd//w5ZgH7ir7RrBnmoGgix7dH8MiOde3cdIyMkYU3YVWNANjZ44zw== X-MS-TrafficTypeDiagnostic: VI1PR01MB4400:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rkzlx6xn8gzKw8HMT4JsRTAoCZ/48ZE9GcLKrBleThRWzRCdMw9bX6O6Ol+3R9S2JF1kP42tUb39+WwJQNsV6I8FdYtg3wfot+deVSVa1tiLve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dRV77D2XCsMqjv+Ku3H5u1IUWd5mdeOqHSlycIOUwyOi6mdAsxkIpkpURpybA/SVpdU37MLGehvq7P/0hukidP0tGEJzoHQJVCloGRVlo2D4dHmR1FoWx8KBEiaSqxOPAJq4ak2foxCJzZ4zbsOvdKkb1jnBVaJpXX0eDAOOyLxQV2HgJjVwpDpy7aqS97fANJxdRHFsK3wI0dFEga9xTrp/GBS1YqiKcyT0Tgs8BtL3rwzrepIU2iTnWG8cyGnmleFwJhysbGks/SSlJel1p95YRpBL/xEJZwd9KxU2aw73iwsVuhd9qEdh9VqeuW1z7lJSZG7U70/oigmJtPZbsSk0abaDK3G86u8xvQp8UoGYcVV+KaBMCatbVMn0yjBQKEE1HOjxcYjbE4s12Rn0Qb1JikWNeq6yEie6LQEgvji/Eq31MEnu3UcOGhGVhCwf5FrRl9gV0vhKXkLjWmWZL5chwVCoBM6ri6SQbw1yZxi0CPDzXjGlGdLArEqkHe70QM1CB9LChQTnrTnytDm2TPec3pdZ4FI3e3yJoQtJ4ysiU2TAokI7tKOELVAVyVjDeCc4xdu/Z+NFUpFAGBXZFmtLtFeavgQRyFx4Aq6yd6KQQ43EK8ZVKO9s385TmATzmADp9BaaQIW2CfJs0MLLU6vjPNqdVAnIXhgqoZuApDDAaBm+QdeTXFjh/mqr02Bxc0/lS2Z3C672BS0IQaxBcPZRXq8z0M0/KrHE76w6G2bhLa692IMRCf0AkvN6WSNNBsgWFKyPe/gFAgsqGQdlqq3cCkkut9O1RRmTMmNz2mKvRSbS908/sxgbANBeO/077JQmXK9eroW0Orf5rg0QgaD6+MG9hhEHcf9CRY= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8c3726d-1781-4652-1a46-08da77d10d36 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2022 17:28:18.4553 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR01MB4400 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/nvdec: Check av_buffer_ref() 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: H6TWi543H/SY It (unfortunately) involves an allocation and can therefore fail. Signed-off-by: Andreas Rheinhardt --- I don't have any nvidia hardware, so all these patches are untested (apart from ensuring that they compile without creating new warnings). libavcodec/nvdec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index edff46d310..15665b83bb 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -532,8 +532,11 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame) } unmap_data->idx = cf->idx; - unmap_data->idx_ref = av_buffer_ref(cf->idx_ref); - unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref); + if (!(unmap_data->idx_ref = av_buffer_ref(cf->idx_ref)) || + !(unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref))) { + ret = AVERROR(ENOMEM); + goto copy_fail; + } av_pix_fmt_get_chroma_sub_sample(hwctx->sw_format, &shift_h, &shift_v); for (i = 0; frame->linesize[i]; i++) { From patchwork Sat Aug 6 17:39:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37163 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a9:b0:8d:7f3b:94fc with SMTP id q41csp900531pzg; Sat, 6 Aug 2022 10:40:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5134KitmHVczYrxakfMo2JkfG9b7DvBg7QdvQOiQSTHNJCq3PiL4K/ZIWHqac/r4BnNo2+ X-Received: by 2002:a17:907:97d1:b0:72e:5ee:2ea8 with SMTP id js17-20020a17090797d100b0072e05ee2ea8mr8622800ejc.592.1659807611438; Sat, 06 Aug 2022 10:40:11 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id go38-20020a1709070da600b00731148bc546si3066489ejc.38.2022.08.06.10.40.10; Sat, 06 Aug 2022 10:40:11 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=DEk8GJlU; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9263B68B649; Sat, 6 Aug 2022 20:40:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-oln040092068041.outbound.protection.outlook.com [40.92.68.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6036D68B53E for ; Sat, 6 Aug 2022 20:40:00 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TT8Sce7zaP1bEb+GbxV/0whFJ7AsZS9fkwXorkT9itWbNX43hqReXJS/k4LxKdP+jWzecsYq01jJSYbj3akWHcy7kFwakiFs9BYI1UuQ8WMbbCol85n25nA/+0oq7uQe+eDbpy2ZFg8m6OJ+rp2zOzFelVR+WmshFVUeOY9RE2/ToMyRuKhlmMc7DahA/yYtaT1PlKBFdq/GkQ2pKkFF0kvEu3ADZkE5UF5TBq62spk4JqL4sxU9XMRz+Mpm9r/FUIzFIjpwaeMuoQV4iwMs+y54IFgWDs7KQ56pAV6BuEPLI30NLbyk5HThvpDW3Vt0fMmNSdZVSKrtiJfQVQXdAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5wLZlQLoGGaSPfGLS0PXIUPKR3K1pf3l+K/SrmQ3ESw=; b=fDItpwYIERidmtoo81SWXUwN4xU92Lk0Q8GVAFVVCsxC634U5YAgE3GptUDYoRhAl+zyNFqBb0B/V9mw8Z3i2/6nxkmv4mjvg5HiGX4gs3lCqFH+37PQc1zmp3DX3FJHYwJepsXLTbNYYULqxVTcT3G06eKZF3Ejrj2cIMnywQRd6rmfS5UBfNdCw+ZnLfd4qqosfqBjQ1KDd2kJIa7ljDJhr282X9VYSKHlwbnNVJYYn5y4DJJ3iVPDG1wPS2txcb0To1S5ts/nM4Sm/pwUWFPLXhxlZKYcpfhub4OWUJOiD7JSEX6X2S+zre0Gcic1fTE/g6i9vi3G5UfjQqCo0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5wLZlQLoGGaSPfGLS0PXIUPKR3K1pf3l+K/SrmQ3ESw=; b=DEk8GJlUusZg5rBaNzkx2SRKwYLeoMO1t6gK9ksj0VGiu5IK8xjWzWqi93mOnPVe5uMc7Q5U9qYxVh6njWM2hOqVSSPbr/wIfLCLzU+yq7M6N75LQ7AT0Av0L49A4QJqYtCO07XGKFLq+sK/1Glq9vL2hKexn9DkTQjfAi1hRKrfCGRRgVyJPyvsZkncsfxPB6cHKIv9Z2X3s6XUXuqB3IbyjH2dwtPnjg772CIg/yWN/F+XHjBmIGBm1bFlEObJP/Y1zLePIsInkLXsyL18JCtWL//hBg/3l2NmSfNEfmHBGwi8P3F3LqAHKrlTOUY8i41yVmTf1SccArupwa9y1A== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by DB9PR01MB7180.eurprd01.prod.exchangelabs.com (2603:10a6:10:212::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Sat, 6 Aug 2022 17:39:58 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46%11]) with mapi id 15.20.5504.016; Sat, 6 Aug 2022 17:39:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Aug 2022 19:39:47 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [2lBrJK5GVbCzNUohxi+oM4FXeRUHvlCB] X-ClientProxiedBy: AS9PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:20b:531::29) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220806173948.294863-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63a6fcb6-9ead-4773-9743-08da77d2ae7f X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNXYfOqwd1ucqK0pZo26bPpvsJqAEJGegze2UwphspaCqFrJmvLcwPiTSt7UT8SNTU1OcuBaaPo//0mvztpbF/eGoW1pzJ/tm7VJqB9pGp3Qe19nY2nK2TkG2vHNVvxy8jzMbx+panwsxhZQyxeE7tQazP0fGy064sDBFKhhGJCPcwqp/pbQjMUyINGrh/cXvT0Eca970K/dtOKSJZBYaXj5aJa/vCOncAvAaeLzYWZYlWLjJOrbY8w7DJyVF/9f5fNQe6QOD6BhXHxmroyyJC9k/ON+BGuW3lp8kR59g3XcXIOjbhkS/DpXTurkISFcwdXLcFmioZMN7y1j72udx9GD2ZV/amsQvINqgsGP27yp/m2C5nINx24YBWTbMrGCIROJGSeFrcCEwaLdGp/OOusuJeQ3LXkx37Ljv9Ush/lQDcZ+ugsg2H6LtEqrL0e0zcG6oELotpkrOz3h8RHQbG58MgKe41viHibCaXbLIXL+3BcAyaSGCoJfZlHhDj9lkKeuGKF44jSPfIF+Ov09p57iVM6six93mHcqmGvEBlVmRoAWYQQXt3W1bQdCBYTDVMO5h4u6CV04RtwCz+6AJGe5pTyjIT3Q1L4WogZtw/MOjnDKr0+ce2ixi+67bql3s8MIHy2fsmik4Rz4Zdr1eTD4RzCWifEwhtZKFCRuSM6JAmdkfUj+BG7Vq3eKeBbvwk5XUhmyirPNIrq4pgXqyTmC6pKMWxw6Vfo= X-MS-TrafficTypeDiagnostic: DB9PR01MB7180:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ri3HO6HEAuix8w5o/IB1wnf6NyNPQYAPvwq0IBYjGcLQ8wrMHC2ugVpLf75zQ/AT47xb4/v6RlU0VlEy8EKvvOrh2743qnAeUAndw2Rfy9CiW2Wu5o9cxtnkYroEh6yc7Evv9tUBH5+K8pvGG2G+6j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5KLitJKCJv+MeDfLoKmlz9vY/v3T/xjxNsidkJQG3FrFyLIQCPmg238CuykU0hVCuWjhi3tk2Cf1FAiv25wEFXKMimZ8i7WOIJbYGSZPFCYBPRgcb31R+m1L61b+thyT/7rKyUgPa8RVdzgz7eTAZfStYubtjtEGuyA3cSP8/zK5206PyViCEMzmEa5SJ+wIWQ5kxTqBBqpXkKrjVDOgff8PppQG6qMCcDovAJ8qNTd+X0JyAxSpwo9JH48yWP6XiLzRcyi4dzQwfREA9W1F7Ofn5tA6OBMhxSXinBkRUV/HfWb11rLryTMLDOBegjIyC1pHhXy9zcqF4W+iOcJ1S/X9S1vM9CZSDxYf6rA2DPTKXqFwZgPh1O+vVIYoOjjHc61aXl6PdG85CMPATnfn2kWvjksYcoe3O0HSz3NDRAP9C12ZM1khdFIJjFVuVyb3is7HYynbDp54mmWofSbVMxHcPZjOTAzTmvd+ylERiKCq323RVKO4l2DfPVGyZl7dvGJrWZnBsa+DOylSsm7qt97Svtfbg7CdUw3mG+j5BJJ5MbZ2W0p5ofjtJL22b/hGBM/luGZ1B26q/MmeT1jKFMUi4nQqDJdE4HjGxOWflFOWdzyUrfrEi0DnX4HZqXOvtdhdynnrH1pc9Lf8FRq8i0m5pWowhMh0TJSQM2JW1mx7NsagroHrzv9Q+QQrmDGyobhWV2CvCK6slIBrIfbYP8s2SzRyCOkzd9xNkYoYgJ69WfBJYH/lpkpAE1VCXSZBZ/aaQh/gJajIzIiQzgTuaVChGSiAX1UUyyoKDLspPuHzBiTZR4xUYetI= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63a6fcb6-9ead-4773-9743-08da77d2ae7f X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2022 17:39:58.4062 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR01MB7180 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/nvdec: Use av_buffer_replace() where appropriate 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bhviRW8oZVpb Signed-off-by: Andreas Rheinhardt --- libavcodec/nvdec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index 15665b83bb..fbaedf0b6b 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -524,12 +524,9 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame) goto copy_fail; } - av_buffer_unref(&frame->hw_frames_ctx); - frame->hw_frames_ctx = av_buffer_ref(decoder->real_hw_frames_ref); - if (!frame->hw_frames_ctx) { - ret = AVERROR(ENOMEM); + ret = av_buffer_replace(&frame->hw_frames_ctx, decoder->real_hw_frames_ref); + if (ret < 0) goto copy_fail; - } unmap_data->idx = cf->idx; if (!(unmap_data->idx_ref = av_buffer_ref(cf->idx_ref)) || From patchwork Sat Aug 6 17:39:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37164 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a9:b0:8d:7f3b:94fc with SMTP id q41csp900606pzg; Sat, 6 Aug 2022 10:40:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR6HfITaDDQ0OOOVfEFLqNFmtDisl5rGad5Hz8d0fMPxT2fcT4IVW4CMOJ7j9aaQ7H75JNrO X-Received: by 2002:a05:6402:1e8a:b0:43e:93ab:5ab8 with SMTP id f10-20020a0564021e8a00b0043e93ab5ab8mr10997715edf.211.1659807619892; Sat, 06 Aug 2022 10:40:19 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dt22-20020a170907729600b0072b2e31d066si6619391ejc.642.2022.08.06.10.40.19; Sat, 06 Aug 2022 10:40:19 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=qjSAeL52; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 57CA068B6AC; Sat, 6 Aug 2022 20:40:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-oln040092068041.outbound.protection.outlook.com [40.92.68.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E7C168ABEC for ; Sat, 6 Aug 2022 20:40:05 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E2/s0MHqVID3gRdcaRsZbbvsKtItgqkXRBiO6Hy4DNAPmz+4NbHDJ/+AVeKHzYFtN6kDnsxy1Oq2sooKIYRZmKG9dTd9YHZnjd+atJCuZFkFp8NPv3LS97BVfzIT8+G24Rjq0y2GWGJqDwLOAdxvIHyuJ4W9d8SIAoBoSOiwIKNSSJF1dlAXN2EtMbbPYin2yBSHCGtq/SJg+683j4mrvHcSR99s7jjIbiB/cJHg70UgUNgfvXAB71X3i10q8QAHfpsASHVvF98Jbgnpqfoo/bXUUtt1TTBFr3aJ8RTySmkT+ZifCjLf0Lf0iTI/eIjdTV0yXpTm/0QxQ1RbZ9ZaQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5QQkqhekL/XgDlCIrBY4g/NiuDP179cY3yaJ3L0ttow=; b=obPIrBUHrPmhsIMJvJyN4fDmZCOI/4OWGfWmfm5ok4QntddJNt62XE+eh8dNHVFQGMrFY7dML0ohKHLONz7O/rthml7lTvA1/e1Ykk3RxeBLKFVbW/oFgxXoxirhP9vwdnCbSZ+QKr42co3qZKG6WAToTFGutiL/6wT0uHFNbRvIxlWNAxHnFmMb0KV8XP7e5XIcz67VTO0hszLzHPzLR2nqWaiKa19OYcPzD7HhSGIJWpgUybGparkTTLEeT9w23meYzaFoswmny37chyEj3sweTVyBWTtZJIUavtNrHjoImh49vYKcP7w+CfJyAZ4rnGUbV9mGkcuAv3Fum0JVGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5QQkqhekL/XgDlCIrBY4g/NiuDP179cY3yaJ3L0ttow=; b=qjSAeL52tdZViniGPjGmNI7od7F7YZAnUiLGvx+gLO4xZ4JByENliNHaGmDUfSsxWFaZBEQwgtSytotGJl4aDeObRXuLSFh2j4qXhkBnWEZPLLA0Zwlma8eTIxWQojZ98H83Gx3Ds/II2fgIzOJXol4IgXgKp/go9iBXP8JIa2GXVjSnNrmntrvr302Mlnw3rje5bQWpM60ALQilCK5OM0mEbOH/U4BPSBSzs8NzxX3OAS66p7JS9Yo6A0XYrUjzmZtZTd8ep6hYzyc+fnuGUDUWJCn4wA2YFvNK6wqnvPxhlZTqOk5zjpIAwnhc17gQQYg7R3gMISRiM8GfWZvz2g== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by DB9PR01MB7180.eurprd01.prod.exchangelabs.com (2603:10a6:10:212::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Sat, 6 Aug 2022 17:40:01 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46%11]) with mapi id 15.20.5504.016; Sat, 6 Aug 2022 17:40:01 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Aug 2022 19:39:48 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [wsnYwlhHQTxAyDSYzV2+EpXAWP+ZizAW] X-ClientProxiedBy: AS9PR04CA0130.eurprd04.prod.outlook.com (2603:10a6:20b:531::29) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220806173948.294863-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 26959722-251f-4012-2b92-08da77d2b042 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNXYfOqwd1ucqK0pZo26bPpvMvR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sfjWGIp2P110vAChK+bQUGE5pT2rJatEIlt3a8sYH8VHOief3yrKx+g8/P6WQaws09mWA2IO79Wxw2JDakEUrs3CSGPHVzBio1j/JG5yaJvg0PJaevESsqNCKxBp0X2/Xlg+Hr7BtUrDxTZVaAleMMaohgMxnSJzkCO3U5T6PCD3RcWCaR9TWfV5cVXCSak7COMYDsL9AbQhzt9T0SnP891NmHrUnTMPCrNwGTGnXIoRevXgXGUltHREstm12NLd8CVEbmfZ/0PSwdPjx+uEBmOPTnIm+TMVBTBIaf4Lt5MCZgZzpC9o0fgo3OLgKv8LVBHY/OjTPw2bYKOXXXquPnvvWCWtdF590kK6JKFvgX2Kc2lLQ6AS5chSHIQVIponih37tenoLMzC0NJEyhqgbREIzHzRZwsoWuhb8/N8uTDf5i7H20zpDjvJG9cwWeZXU9Bh6nWbBIHiDOpJku5fNCqSTqMlK7GcApTELZKH8PQXtEN1cs9CLL57FqAtPxc6mC6PTKZGFmQyu4KxQ6OUT1nD8a++3f4fWdBUXpZ4AWM7XguLM6LKDahOyaSpaBW2OFWEvF5XZD0Dzq5iTAjQ2GPJbMxdhk1MRCyfwzgWswNuxAITsbC+hQsFyd1glBkBmO80z7w3HBl34NW+CaVepkVOMAvnu/LyHWiaKH6P36dmxoIzo= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26959722-251f-4012-2b92-08da77d2b042 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2022 17:40:01.2654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR01MB7180 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/nvdec: Redo handling of failure in nvdec_retrieve_data() 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9rubX1+52yJ9 Said function has a block intended for failure on the main code path that is jumped over when no error happens: goto finish; copy_fail: /* cleanup code */ finish: /* more code */ return ret; This commit changes this to the more common: finish: /* more code */ return ret; copy_fail: /* cleanup code */ goto finish; Given that the cleanup code depends upon from where one jumps to it, it is also split into two code blocks with their own labels, thereby avoiding the check for which case one is in. Signed-off-by: Andreas Rheinhardt --- libavcodec/nvdec.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index fbaedf0b6b..0a4fb30b42 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -513,26 +513,27 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame) unmap_data = av_mallocz(sizeof(*unmap_data)); if (!unmap_data) { ret = AVERROR(ENOMEM); - goto copy_fail; + goto early_fail; } frame->buf[1] = av_buffer_create((uint8_t *)unmap_data, sizeof(*unmap_data), nvdec_unmap_mapped_frame, (void*)devptr, AV_BUFFER_FLAG_READONLY); if (!frame->buf[1]) { + av_freep(&unmap_data); ret = AVERROR(ENOMEM); - goto copy_fail; + goto early_fail; } ret = av_buffer_replace(&frame->hw_frames_ctx, decoder->real_hw_frames_ref); if (ret < 0) - goto copy_fail; + goto late_fail; unmap_data->idx = cf->idx; if (!(unmap_data->idx_ref = av_buffer_ref(cf->idx_ref)) || !(unmap_data->decoder_ref = av_buffer_ref(cf->decoder_ref))) { ret = AVERROR(ENOMEM); - goto copy_fail; + goto late_fail; } av_pix_fmt_get_chroma_sub_sample(hwctx->sw_format, &shift_h, &shift_v); @@ -542,19 +543,16 @@ static int nvdec_retrieve_data(void *logctx, AVFrame *frame) offset += pitch * (frame->height >> (i ? shift_v : 0)); } - goto finish; - -copy_fail: - if (!frame->buf[1]) { - CHECK_CU(decoder->cvdl->cuvidUnmapVideoFrame(decoder->decoder, devptr)); - av_freep(&unmap_data); - } else { - av_buffer_unref(&frame->buf[1]); - } - finish: CHECK_CU(decoder->cudl->cuCtxPopCurrent(&dummy)); return ret; + +early_fail: + CHECK_CU(decoder->cvdl->cuvidUnmapVideoFrame(decoder->decoder, devptr)); + goto finish; +late_fail: + av_buffer_unref(&frame->buf[1]); + goto finish; } int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame)