[v3] vcodec: mediatek: add check for NULL for vsi->frm_bufs[vsi->new_fb_idx].buf.fb in vp9_swap_frm_bufs
Message ID | 20221111090604.10327-1-abelova@astralinux.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp632331wru; Fri, 11 Nov 2022 01:14:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf7jzqyH3Gds7U0lBLIY9AtQUiR2jkP+o18jGasq0UYaY0/KdJz4nYD0K5L8B3aAYtt28zyX X-Received: by 2002:a17:906:4dd6:b0:7ad:a030:487e with SMTP id f22-20020a1709064dd600b007ada030487emr1167232ejw.508.1668158044121; Fri, 11 Nov 2022 01:14:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668158044; cv=none; d=google.com; s=arc-20160816; b=OOSWzTUCSiWR3T8aE0n2XgWRXXR2rtBVUmrwhBouF1ot8E83H5sKxpEFRJ10Y+kRQS qcqOaB7WsgGrtHm1190CkwhDVMB8VRH0yDbdx9u+hVwvAkG2FHFzmYwGOr9aSdJgxpPk k6Pa7uqZQ0AXJ4OZ+LTKj/u04GXbd638KBVwlD0l2UJ2+Bw9c2aisjHDYqf8C290dcNK z2VLeo5rxy3mB4l2yD7giEiXIsNkx1cYz2PU2kpcafwPDsmyQQHpvVeOqdLUhDxgBCc5 7XIqFhTubenZHGL1JGBS/YVVsNnTd2V+U3Q8ktkVtrXElvGDd99740ZCDAMwvI0hS7Hy BuxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XIwwONpUR9SdSPR3A4IDAkq7FO9Vi6bAN02Uo080t4Q=; b=GG+Ss6svP06sigzDbmfoh0O7sy1IfDCbWPK6F4acJOsoxeFR3LgJuG1KtF1KkseHkL JWe2OXi4Ajgi5FL56+IVDaB8OcihBUkAL3NAs/aASgRy1Qq/DpSI3VVQ9DbklScrb46b J1sLusufKGloQCVKMLuc5TRMYncNNWOOuqVTG6qtk++ILR+z7t320wxVe5bjBhvyCyt2 /0FTbR3Dhyh7zXv8arjO+N+DHgvbXBoIS57TChJieHpX1dEUwI2OPSwbHis+UaDV+RX5 oqzfjDvxW77r0Ep2K1f9qNoipLg86T4gIrJEF9Ayd2toGV+RYv24uJgIOgnxC8+fl6oi 7U3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg38-20020a170907a42600b007adcf0dd301si1681804ejc.747.2022.11.11.01.13.40; Fri, 11 Nov 2022 01:14:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233651AbiKKJGg (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Fri, 11 Nov 2022 04:06:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233594AbiKKJGV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Nov 2022 04:06:21 -0500 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0630D6157; Fri, 11 Nov 2022 01:06:17 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id D34BD1864129; Fri, 11 Nov 2022 12:06:13 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 7TDjB1JgeUte; Fri, 11 Nov 2022 12:06:13 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 83FF11863D99; Fri, 11 Nov 2022 12:06:13 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id aOBzQVoBem_j; Fri, 11 Nov 2022 12:06:13 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.20]) by mail.astralinux.ru (Postfix) with ESMTPSA id A20F61863D98; Fri, 11 Nov 2022 12:06:12 +0300 (MSK) From: Anastasia Belova <abelova@astralinux.ru> To: Mauro Carvalho Chehab <mchehab@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com> Cc: Anastasia Belova <abelova@astralinux.ru>, Tiffany Lin <tiffany.lin@mediatek.com>, Andrew-CT Chen <andrew-ct.chen@mediatek.com>, Yunfei Dong <yunfei.dong@mediatek.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, Nicolas Dufresne <nicolas.dufresne@collabora.com>, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, lvc-project@linuxtesting.org Subject: [PATCH v3] vcodec: mediatek: add check for NULL for vsi->frm_bufs[vsi->new_fb_idx].buf.fb in vp9_swap_frm_bufs Date: Fri, 11 Nov 2022 12:06:04 +0300 Message-Id: <20221111090604.10327-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749190489235264924?= X-GMAIL-MSGID: =?utf-8?q?1749190489235264924?= |
Series |
[v3] vcodec: mediatek: add check for NULL for vsi->frm_bufs[vsi->new_fb_idx].buf.fb in vp9_swap_frm_bufs
|
|
Commit Message
Anastasia Belova
Nov. 11, 2022, 9:06 a.m. UTC
Any time calling vp9_is_sf_ref_fb we need fb != NULL after checks.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: f77e89854b3e ("[media] vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On 11/11/22 10:06, Anastasia Belova wrote: > Any time calling vp9_is_sf_ref_fb we need fb != NULL after checks. This doesn't match the subject line at all! > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: f77e89854b3e ("[media] vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver") Drop this, it's not a fix, it just attempts to make things more robust. > > Signed-off-by: Anastasia Belova <abelova@astralinux.ru> > --- > drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c > index 70b8383f7c8e..776468cd834a 100644 > --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c > +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c > @@ -208,6 +208,9 @@ static bool vp9_is_sf_ref_fb(struct vdec_vp9_inst *inst, struct vdec_fb *fb) > int i; > struct vdec_vp9_vsi *vsi = inst->vsi; > > + if (!fb) > + return true; > + > for (i = 0; i < ARRAY_SIZE(vsi->sf_ref_fb); i++) { > if (fb == &vsi->sf_ref_fb[i].fb) > return true; This won't work: if fb == NULL, then depending on whether this function returns true or false, the code in vp9_swap_frm_bufs() will crash in either vsi->frm_bufs[vsi->new_fb_idx].buf.fb->base_y.va or in vp9_free_sf_ref_fb(). Unless you can show there really is a path through which fb can be NULL, I don't think it is worth continuing with this. Regards, Hans
diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c index 70b8383f7c8e..776468cd834a 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c @@ -208,6 +208,9 @@ static bool vp9_is_sf_ref_fb(struct vdec_vp9_inst *inst, struct vdec_fb *fb) int i; struct vdec_vp9_vsi *vsi = inst->vsi; + if (!fb) + return true; + for (i = 0; i < ARRAY_SIZE(vsi->sf_ref_fb); i++) { if (fb == &vsi->sf_ref_fb[i].fb) return true;