vcodec: mediatek: add check for NULL for vsi->frm_bufs[vsi->new_fb_idx].buf.fb in vp9_swap_frm_bufs
Message ID | 20221028125811.11340-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 l7csp815517wru; Fri, 28 Oct 2022 06:02:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jLwpwY896/H4jaaSJjH9CJWTwMwW22gyrevlipiOyXczeim9p3uKLumo1YkowELkGJx0m X-Received: by 2002:a17:90a:f198:b0:212:c3cf:b8f4 with SMTP id bv24-20020a17090af19800b00212c3cfb8f4mr16359413pjb.49.1666962125570; Fri, 28 Oct 2022 06:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666962125; cv=none; d=google.com; s=arc-20160816; b=oyj5u2T0a8xbOJzkb5OhojdLXm9QFFEuZ2iazbUrBfSxxIBUpsYSLlLUoJQOOPg+Vc oQgHXnWepqJVvqRvLSzL+QhFy4OHdmtIi4tJcdMUU2vIwf1gRk4rNpyfO/hubyOCrK0Y nrXwSxw+VDEK/VB+hhc3I54g61krgqtPf9K2DZtRwhLzjQE3MRX/bXcrtbQjsxru8BEb jLu9ArWbastmZUSVvgh7K6SQ0daGkxtvj4Ul1jYQn6HFy9FjJ2+6DWWIENrMc2gOZVC2 KWLuAhOTiG5ID8PAkMVLSSCPOkgNQNe9WS8Ql870XwrGInt/XxBtODlu3c1Owew7k31C GEbw== 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=PdukXL+14+SCNZvplferwaLudZcQBMaEPikpoQpVCHg=; b=KH5tf7+4Gn2d3roVPCyNe1ArQhXIErs8vOQYJesJjrMALpzc8Ff5QydiTlVhkQQS+x Dig0mr1wm7ffOES6PRZEK2QuAt1pEZ1dty0abtmlzQBrQl9kHpt59GlHtadm1uMAdgJi 0XEpdBp3FKvmKqkzCyPpe0NteHKZ+fjyD1m06cnZuPx/coyVWLsRzJIyl4fyWDFGACkq ilRiAglQY1MWsr4oMZPAaCcvsd/ERJoPKEqd1fWYYBlJ4MKLSXIfmwaWNmZwhOmtQHsH OhFNusMh0UV4bJhNXFHjEIA5ibLz5puL5FFcDW0laVY+AXn8zoieajD5YVkA5YL0gbl7 Sbng== 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 c19-20020a056a000ad300b0053e15843f1fsi6269790pfl.131.2022.10.28.06.01.51; Fri, 28 Oct 2022 06:02:05 -0700 (PDT) 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 S230049AbiJ1M6d (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Fri, 28 Oct 2022 08:58:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbiJ1M6b (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 28 Oct 2022 08:58:31 -0400 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FF3F1CC3C1; Fri, 28 Oct 2022 05:58:28 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 6266A186458D; Fri, 28 Oct 2022 15:58:24 +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 7BSvSK3WxBlH; Fri, 28 Oct 2022 15:58:24 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id ED4DA186458E; Fri, 28 Oct 2022 15:58:23 +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 ud5wkNZ1Usua; Fri, 28 Oct 2022 15:58:23 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.20]) by mail.astralinux.ru (Postfix) with ESMTPSA id 27F931863FEA; Fri, 28 Oct 2022 15:58:23 +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] vcodec: mediatek: add check for NULL for vsi->frm_bufs[vsi->new_fb_idx].buf.fb in vp9_swap_frm_bufs Date: Fri, 28 Oct 2022 15:58:11 +0300 Message-Id: <20221028125811.11340-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?1747936477973893301?= X-GMAIL-MSGID: =?utf-8?q?1747936477973893301?= |
Series |
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
Oct. 28, 2022, 12:58 p.m. UTC
If vsi->frm_bufs[vsi->new_fb_idx].buf.fb == NULL while cleaning
fb_free_list NULL-pointer is dereferenced.
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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi, Le vendredi 28 octobre 2022 à 15:58 +0300, Anastasia Belova a écrit : > If vsi->frm_bufs[vsi->new_fb_idx].buf.fb == NULL while cleaning > fb_free_list NULL-pointer is dereferenced. > > 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 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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..b0679aaf6192 100644 > --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c > +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c > @@ -512,7 +512,7 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst) > * clean fb_free_list > */ > if (vsi->frm_bufs[vsi->new_fb_idx].ref_cnt == 0) { > - if (!vp9_is_sf_ref_fb( > + if (vsi->frm_bufs[vsi->new_fb_idx].buf.fb != NULL && !vp9_is_sf_ref_fb( > inst, vsi->frm_bufs[vsi->new_fb_idx].buf.fb)) { > struct vdec_fb *fb; Perhaps we could try and maintain some readability ? I'd suggest to move the check into vp9_is_sf_ref_fb() as an early return. Nicolas
Il 28/10/22 15:02, Nicolas Dufresne ha scritto: > Hi, > > Le vendredi 28 octobre 2022 à 15:58 +0300, Anastasia Belova a écrit : >> If vsi->frm_bufs[vsi->new_fb_idx].buf.fb == NULL while cleaning >> fb_free_list NULL-pointer is dereferenced. >> >> 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 | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> 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..b0679aaf6192 100644 >> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c >> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c >> @@ -512,7 +512,7 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst) >> * clean fb_free_list >> */ >> if (vsi->frm_bufs[vsi->new_fb_idx].ref_cnt == 0) { >> - if (!vp9_is_sf_ref_fb( >> + if (vsi->frm_bufs[vsi->new_fb_idx].buf.fb != NULL && !vp9_is_sf_ref_fb( >> inst, vsi->frm_bufs[vsi->new_fb_idx].buf.fb)) { >> struct vdec_fb *fb; > > Perhaps we could try and maintain some readability ? I'd suggest to move the > check into vp9_is_sf_ref_fb() as an early return. > I don't think that this will ever happen, as the check was omitted because of being totally sure that vsi->frm_bufs[vsi->new_fb_idx].buf.fb is not NULL. In any case, it doesn't really cost anything to add a check... in which case, I agree with Nicolas about moving that to vp9_is_sf_ref_fb(). if (!fb) return false for ..... Regards, Angelo
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..b0679aaf6192 100644 --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c @@ -512,7 +512,7 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst) * clean fb_free_list */ if (vsi->frm_bufs[vsi->new_fb_idx].ref_cnt == 0) { - if (!vp9_is_sf_ref_fb( + if (vsi->frm_bufs[vsi->new_fb_idx].buf.fb != NULL && !vp9_is_sf_ref_fb( inst, vsi->frm_bufs[vsi->new_fb_idx].buf.fb)) { struct vdec_fb *fb;