| Message ID | 20261102170303.1973892-1-jernej.skrabec@gmail.com (mailing list archive) |
|---|---|
| Headers |
Return-Path: <linux-sunxi+bounces-27051-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mxe881.netcup.net (Postfix) with ESMTPS id 5CB531C4190
for <noreply@patchwork.local>; Mon, 2 Nov 2026 19:35:15 +0100 (CET)
Authentication-Results: mxe881;
dkim=pass header.d=gmail.com;
spf=pass (sender IP is 172.105.105.114)
smtp.mailfrom=linux-sunxi+bounces-27051-noreply=patchwork.local@lists.linux.dev
smtp.helo=tor.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates
172.105.105.114 as permitted sender) client-ip=172.105.105.114;
envelope-from=linux-sunxi+bounces-27051-noreply=patchwork.local@lists.linux.dev;
helo=tor.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 8E43F30B73
for <noreply@patchwork.local>; Mon, 2 Nov 2026 17:34:14 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793638996;
b=4J/sKyNAFKtIV810IyIdH01XscGsh7auU53Gih7mp4J6w6BWTc8n7kWd1svxRW91gJGW
zJbory69dYedekTa83dm4LVMK6W+OvjAgK/yvhoqGq2PTaDu6fG3FXD5kKzcuVi7CTz8V
yq3BsBYw86tTQjBRWeAgSCSUPxOLK7/teTxcU3ZY7jQSB+8ZGeGNEyN5c/nBRkbo2q//w
F3cCU+jpHJlqDyFSuFarD9XzH3LjTJPGypYwVwTYmtJn1/4PZRJX1bYvx+7ZU7XcukIt/
LRn2HLx8NeDOGFvB1yB8/2n6SbVT5AFh62nqBxzP7jMoX5lqRR6cQhZdY9hLUGJg4wA==
ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793638996;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=LyWui7dAfXbBCWh/47kRB3Ky2JFvt+VIP6naoPJCv0k=;
b=rz4qKrGbYWUlXKDyIb4oZtNR5XxCuwdTfEvl/gWHEIVPCjXuHoDbPOLh70lzortA/TsN
Icsq8C8jxjcirXrRrWsV+8IU+6XRfDwTq/yT+z6FHLifK9eYGqMqvjdfInS1gEb7JvezH
OYHLeFBbB6ZDwN74Yl1sAiJlO8utTJ9vJxvd1R/3YrxDOw6ifcBNBenbOa2ouvH5qGNY4
NkcuUwwfOLbDY30pC4LOIjPZSXUusG5Eckr6EVuZRWYrco+Din1iDaQPKSfz/wKdbsKE9
NtSxcjKG3TFGROBv2wObKM7D7E2GC0nMep8Yv0E7T8/aRnuMZG3BY6aApAKbBXUGCbA==
ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
header.s=20260707 header.b=b6GcWqVv;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 3010B606A902;
Mon, 2 Nov 2026 17:03:16 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key,
unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
header.s=20260707 header.b=b6GcWqVv
X-Original-To: linux-sunxi@lists.linux.dev
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.remote-ip=209.85.218.47
ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793638996;
b=crSf55CRT5swVNdkkO9MsxMvtQRKXmxwFEaQ3OfzjPFYrhxLMOXk+uI62hDpknTLUq2+
3+jj5Xd9PQ21hBDt7nUGpSkeE5DzL+z9bjEP0A1y5hGTwBQkGkUQMLgS2GBZtq9UkKlre
GWo+uFRi/VY5qnDw57kxBCgtKYXXCp0zUMJn1+bu9TlDfeOAKANaFEmObCCaf2A0EWwQX
ChsYscGCWAVXVZ5m+R3LQv3EmITpFazRs8Wct7aCshWAHUKHjXmGYHRT/8kfh4XMMA6Wq
oZnzkOT7hTmYCFaO57BCuMz45efCDDCLKv8YEiNQ04kk+PMEvrdMt8gfp6g/uV1lHJQ==
ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793638996;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=LyWui7dAfXbBCWh/47kRB3Ky2JFvt+VIP6naoPJCv0k=;
b=Jpym2U3oJvoqe/outbAkKhd2QA0JxSIVd3M3wB2hGUfuOvIASyS5lTa41xWpRv3As+Pr
mTuS6lrR+foERp9gyJwMzzXgA289EauL+wL5+oKhcec7L4U+9dkcOvfpi+tdCIBjcCvAV
uefEwmJEWYWe6fKLDD6RC9kh7yh4BRHY7Hm5lKN05Sc/ItlFCoxNizRYcN3Y/iDx64qsH
seW45HiBn2oXlIwskoOXg4Bfy+LbCknFphWnuJIndZ3Yg30STB5+dudvp4Emu+gMplYuS
gAJsf1UalLrBPFl1+t/vkJGqBtxQGDm/m/fZ7DP9+OU81N+s4iagfKA0Em68r0kREfg==
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
header.s=20260707 header.b=b6GcWqVv;
arc=none smtp.remote-ip=209.85.218.47
Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com
[209.85.218.47])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest
SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBB0C606A5A6
for <linux-sunxi@lists.linux.dev>; Mon, 2 Nov 2026 17:03:15 +0000 (UTC)
DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BBB0C606A5A6
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=gmail.com
Received: by mail-ej1-f47.google.com with SMTP id
a640c23a62f3a-c247f6687dcso567035466b.2
for <linux-sunxi@lists.linux.dev>;
Mon, 02 Nov 2026 09:03:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793638994; x=1794243794;
darn=lists.linux.dev;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=LyWui7dAfXbBCWh/47kRB3Ky2JFvt+VIP6naoPJCv0k=;
b=b6GcWqVviwPkNc2hUrUD7vnf5jp98+FptutNIuktSeE9uphenyTkiWTokZ1KVN3WTW
694cI3NoSs8OjOSdRMCgmujneuC+YE2Q3mCeCXKWux8qfPRtVC9s+e4pO2Q6lmKYlKRI
dXYj6eFAf3TOwsAU34sQkrMiYQ0HffhZUdEx3MLpepzyl7oFeCdfOgLa1W7BxFnTeHmD
raTffUowLfXR57P95555hRZN6ATtywy/5cwAoPZ+fPGrGNc+os5zhic2Een+ytA97tMo
yf62njGDz48YUJKsCOR8Ctmz9fVO9cLSIZLJNiDmoMHNEN7DVo9XNP/rJg+dI+WX1WJs
x+Pw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793638994; x=1794243794;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=LyWui7dAfXbBCWh/47kRB3Ky2JFvt+VIP6naoPJCv0k=;
b=tBV1P6oHAM65wcudXFw1u3eZIA9bluvePaaH7HFarjBkvaUI+R0N4R/8ROUiTRKtKE
Qnkpp0G4ZznQLfPiAWLazcQ+FMarkB+eBUk97RUe3YBjYqO+35U/fASrxovOwdzo3mkv
PgELek+fdLhAwahsErxZCdMmvpjI/lBK5VV1ucyCDmqYAyJGzV7awC/1bDbzaydtkUee
sbDLniqZKWNn40t+uWNW7xPMsetFBSAsZSVpm+cV5RBSfbixo1SsWA0Ixc0LXqNY2FCy
J5gvtPDQCgEfvO27gZf3IaoEGcQ556fWtfr+xpQQdfICPoW2xbQL8quhVO/OiGTwJINl
q1jA==
X-Forwarded-Encrypted: i=1;
AKwUvByAoyKV0d/+T9yQMvURIgP/UXNHTvhZ+oiRx7744foP/b/II09B8PhMmyqlg7070TOVVBHlMmI9CG4VBQ==@lists.linux.dev
X-Gm-Message-State: AFq9FYKianMbL2wIIRQvqbmqkqBnkfiIE6b9XvbMB2Sf5hpgXKXAvWUF
X51fTVVthnoAF+3rRr3JFTlp4kNFT97FyEWRVaYp+s7UiLCmTEPc+tKJqWyxdg==
X-Gm-Gg: AYBFou1EQiP1ahENyPU3hbLtyDgpyphSPSPhlcQOLeSa8Q+CwI4vMvge8e0mD02l2J4
Lo91BbhK0RLeagPs6ZIRBDH/QMo0PoHIzeXzJbEepm21g9phmuHKvK1nO4eUTjE7rf/KiAGiIhz
VptEMR2p/7zKfM0OfE1CGGk3gC9gRSBxKedooiZEnHoma0D8d6ZW3Xijkv/ukbBo0EH6FhJgbvq
Uymno1JJpnQEPyHl5Ndt+EBbJVNabFCJ0z4L2uVNUaVtnjuLUNpmqGHzxySsyXDKARVOKP759cr
oDjAbzvDPdHIfmOyojtyk0HPku8SDKqdTwcd+rDozbrFfz9AW7jvhuObw+n+N9Wej25IwraVxVZ
1oQ0RsLyyVsmMgm4ScnQHpdYUwLw7YE9hNk6pFSFVZqm1nB8fW7zWY6/FaggnCgVJBIZ36f5WWY
AGvIC0KC4PhGo9dya7Y1M3eMfZYexbA9NIjnBfftcjmHSNEGV3HVsMQUPtMKm15O701ny8a7rCH
6oA/+QaQ0+Ab/708JyzX9TwUg0DAmbLMfa/7HX8ZlKAmiFFUZNPxNoBi1c21IBv+/c40GTmNc6S
x3j8o/n+KMBECt8GxkVUNq7J9YghNlUHseHPUGzjDQBtiZIOG1wUe7Mz7xcHVawLi+EKZycovdw
XXWrnvj1NXViFZLJB1nhYexo5BZdf5ZcLpXTDXsKztQNG4PxcTrX6znDn3wb43cQVMgMFML1ma4
5Xh3nsNBQ4/GPn9JuUIvQs/NoGc+Nfsidcmh0B+yU2fUhZJPNvsWwvDhYGcIIcUgMcWVXI/4MSS
wa+11SkoQepkUM2ektOTdYDgXd5O0bj/B+KCv5AaBNyUvZZHw==
X-Received: by 2002:a17:907:e8f:b0:c41:64c1:cc2d with SMTP id
a640c23a62f3a-c4ca79353a4mr832997366b.2.1793638993799;
Mon, 02 Nov 2026 09:03:13 -0800 (PST)
Received: from jernej-laptop (194-152-27-116.dynamic.telemach.net.
[194.152.27.116])
by smtp.gmail.com with ESMTPSA id
ffacd0b85a97d-48e71a4d3cesm23362309f8f.7.2026.11.02.09.03.11
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 02 Nov 2026 09:03:12 -0800 (PST)
From: Jernej Skrabec <jernej.skrabec@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>
Cc: Maxime Ripard <mripard@kernel.org>,
Paul Kocialkowski <paulk@sys-base.io>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Chen-Yu Tsai <wens@kernel.org>,
Samuel Holland <samuel@sholland.org>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
linux-media@vger.kernel.org,
linux-staging@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev,
linux-kernel@vger.kernel.org,
Jernej Skrabec <jernej.skrabec@gmail.com>
Subject: [PATCH 00/10] staging: media: cedrus: assorted fixes and VP8 4K
support
Date: Mon, 2 Nov 2026 18:02:53 +0100
Message-ID: <20261102170303.1973892-1-jernej.skrabec@gmail.com>
X-Mailer: git-send-email 2.56.0
X-Mailing-List: linux-sunxi@lists.linux.dev
List-Id: <linux-sunxi.lists.linux.dev>
List-Post: <mailto:linux-sunxi@lists.linux.dev>
List-Help: <mailto:linux-sunxi+help@lists.linux.dev>
List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev>
List-Owner: <mailto:linux-sunxi+owner@lists.linux.dev>
Precedence: list
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Rspamd-Server: rspamd-worker-8404
X-Spamd-Result: default: False [4.81 / 15.00];
RBL_SENDERSCORE(2.00)[172.105.105.114:from];
SUSPICIOUS_RECIPS(1.50)[];
DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed),
No valid DKIM,none];
R_MISSING_CHARSET(0.50)[];
MAILLIST(-0.18)[generic];
BAD_REP_POLICIES(0.10)[];
MIME_GOOD(-0.10)[text/plain];
HAS_LIST_UNSUB(-0.01)[];
ARC_ALLOW(0.00)[subspace.kernel.org:s=arc20261015:i=2];
TAGGED_RCPT(0.00)[];
RCVD_VIA_SMTP_AUTH(0.00)[];
DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:helo,tor.lore.kernel.org:rdns];
RCPT_COUNT_TWELVE(0.00)[14];
FORGED_SENDER_MAILLIST(0.00)[];
FREEMAIL_CC(0.00)[kernel.org,sys-base.io,linuxfoundation.org,sholland.org,collabora.com,vger.kernel.org,lists.linux.dev,lists.infradead.org,gmail.com];
FROM_HAS_DN(0.00)[];
MID_RHS_MATCH_FROM(0.00)[];
ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG];
FREEMAIL_FROM(0.00)[gmail.com];
R_SPF_ALLOW(0.00)[+ip4:172.105.105.114];
TO_DN_SOME(0.00)[];
RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.77.114.92:received,194.152.27.116:received,209.85.218.47:received];
RCVD_COUNT_FIVE(0.00)[6];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
RCVD_TLS_LAST(0.00)[];
MIME_TRACE(0.00)[0:+];
FROM_NEQ_ENVFROM(0.00)[jernejskrabec@gmail.com,linux-sunxi@lists.linux.dev];
TAGGED_FROM(0.00)[bounces-27051-noreply=patchwork.local];
RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.105.105.114:from]
X-Rspamd-Queue-Id: 5CB531C4190
X-MORS-Enabled: yes
X-MORS-DOMAIN: patchwork.local
X-MORS-HOSTING: hosting172546
X-MORS-USER: hosting172546
X-getmail-retrieved-from-mailbox: INBOX
|
| Series |
staging: media: cedrus: assorted fixes and VP8 4K support
|
|
Message
Jernej Skrabec
Nov. 2, 2026, 5:02 p.m. UTC
This series fixes a number of bugs in the Cedrus driver, found while
running the conformance suites and comparing with the vendor library,
mostly on H616.
Patches 1-9 are fixes:
- patch 1 fixes MV-col buffer leak when the file handle is closed
without STREAMOFF,
- patches 2 and 7 validate H.264/HEVC SPS and VP8 frame size against
the hardware limits and allocated capture buffers, preventing memory
overruns and hardware hangs,
- patch 3 marks H.264 long-term references, which fixes MR8_BT_B and
MR9_BT_B conformance samples,
- patches 4-6 fix MPEG-2 field picture decoding (field height, field
order detection and references of the second field),
- patch 8 enlarges VP8 probability table to the size used by the vendor
libraries, since the hardware uses the area past it as scratch space,
- patch 9 switches H616 to the 256-bit DDR mode, which fixes corrupted
reference chroma in H.264 and VP8.
Patch 10 is new functionality: VP8 decoding of frames wider than 2048
pixels.
Please take a look.
Best regards,
Jernej
Jernej Skrabec (10):
staging: media: cedrus: free MV-col buffers in buf_cleanup
staging: media: cedrus: reject too large H.264/HEVC SPS
staging: media: cedrus: h264: mark long-term references in the frame
info
staging: media: cedrus: mpeg2: use the field height for field pictures
staging: media: cedrus: mpeg2: derive the field order of field
pictures
staging: media: cedrus: mpeg2: fix the references of field pictures
staging: media: cedrus: validate VP8 frame size
staging: media: cedrus: vp8: use the vendor probability table size
staging: media: cedrus: h616: use the 256-bit DDR mode
staging: media: cedrus: vp8: support frames wider than 2048 pixels
drivers/staging/media/sunxi/cedrus/cedrus.c | 60 +++++++++++++++-
drivers/staging/media/sunxi/cedrus/cedrus.h | 15 ++++
.../staging/media/sunxi/cedrus/cedrus_h264.c | 40 +++++++----
.../staging/media/sunxi/cedrus/cedrus_h265.c | 28 ++++----
.../staging/media/sunxi/cedrus/cedrus_hw.c | 14 ++--
.../staging/media/sunxi/cedrus/cedrus_mpeg2.c | 72 ++++++++++++++++---
.../staging/media/sunxi/cedrus/cedrus_regs.h | 8 +++
.../staging/media/sunxi/cedrus/cedrus_video.c | 15 ++--
.../staging/media/sunxi/cedrus/cedrus_video.h | 5 ++
.../staging/media/sunxi/cedrus/cedrus_vp8.c | 66 ++++++++++++++++-
10 files changed, 276 insertions(+), 47 deletions(-)
base-commit: 27285b099fbc5cb2ae3aef20f3bbd7b3c88b3005
Comments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] media: cedrus: SPS size check in cedrus_check_pic_size() bypassed -- commit 22d806de7dc3cc25db6d7871ebfc3e81dbda3078 Author: Jernej Skrabec <jernej.skrabec@gmail.com> staging: media: cedrus: reject too large H.264/HEVC SPS This commit validates H.264 and HEVC SPS picture dimensions in cedrus_try_ctrl() against hardware limits and allocated capture buffer dimensions to prevent memory overruns and hardware hangs. > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c > index c3331b4f3f020..45deebddb630e 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c > @@ -28,10 +28,38 @@ > #include "cedrus_dec.h" > #include "cedrus_hw.h" > > +/* > + * The hardware decodes whatever picture size the bitstream headers describe. > + * Reject sizes beyond the hardware limits, or beyond the capture buffers once > + * they are allocated, instead of letting the hardware overrun memory and hang. > + */ > +static int cedrus_check_pic_size(struct cedrus_ctx *ctx, u32 width, u32 height) > +{ > + struct vb2_queue *vq; > + > + if (width > CEDRUS_MAX_WIDTH || height > CEDRUS_MAX_HEIGHT) > + return -EINVAL; > + > + /* > + * The hardware decodes whole 16x16 macroblocks, and all capture > + * formats pad the buffers to at least 16 pixels in both directions. > + */ > + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); > + if (vb2_is_busy(vq) && > + (width > ALIGN(ctx->src_fmt.width, 16) || > + height > ALIGN(ctx->src_fmt.height, 16))) > + return -EINVAL; [Severity: High] Can the check against ctx->src_fmt in cedrus_check_pic_size() be bypassed when V4L2_CID_STATELESS_H264_SPS or V4L2_CID_STATELESS_HEVC_SPS is set before capture buffers are allocated? While vb2_is_busy(vq) is false on the V4L2_BUF_TYPE_VIDEO_CAPTURE queue, cedrus_check_pic_size() only checks that width and height do not exceed CEDRUS_MAX_WIDTH and CEDRUS_MAX_HEIGHT (4096x2304). Unlike the HEVC bit_depth handling in cedrus_try_ctrl(), setting the SPS control while !vb2_is_busy(vq) does not update ctx->src_fmt or ctx->dst_fmt. In addition, cedrus_s_fmt_vid_out() in drivers/staging/media/sunxi/cedrus/cedrus_video.c allows userspace to shrink ctx->src_fmt and ctx->dst_fmt (down to 16x16) at any time before capture buffers are allocated: drivers/staging/media/sunxi/cedrus/cedrus_video.c:cedrus_s_fmt_vid_out() { ... peer_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); if (vb2_is_busy(peer_vq)) return -EBUSY; return cedrus_s_fmt_vid_out_p(cedrus_file2ctx(file), &f->fmt.pix); } Also, if userspace never sets V4L2_CID_STATELESS_H264_SPS, the default zero-initialized control has V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY unset, giving a 16x32 picture height while cedrus_open() initializes ctx->src_fmt and ctx->dst_fmt to 16x16. When capture buffers are subsequently allocated, cedrus_queue_setup() sizes the capture buffers from ctx->dst_fmt, and cedrus_h264_start(), cedrus_write_frame_list(), and cedrus_h265_setup() size the auxiliary DMA buffers (pic_info_buf, deblk_buf, intra_pred_buf, and mv_col_buf) from ctx->src_fmt. Neither cedrus_start_streaming() nor the codec setup callbacks re-validate the active SPS against ctx->src_fmt. If the larger SPS was set on ctx->hdl before VIDIOC_REQBUFS(CAPTURE) and subsequent requests do not attach a new SPS control, cedrus_try_ctrl() is not called again after vb2_is_busy(vq) becomes true. Even if the oversized SPS was attached to a media request before VIDIOC_REQBUFS(CAPTURE), cedrus_device_run() in drivers/staging/media/sunxi/cedrus/cedrus_dec.c ignores the error from v4l2_ctrl_request_setup(): drivers/staging/media/sunxi/cedrus/cedrus_dec.c:cedrus_device_run() { ... if (src_req) v4l2_ctrl_request_setup(src_req, &ctx->hdl); ... ctx->current_codec->setup(ctx, &run); ... ctx->current_codec->trigger(ctx); } Wouldn't this still allow the hardware to decode using an SPS larger than the allocated capture and auxiliary DMA buffers, overrunning memory and hanging the VPU?
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] media: cedrus: vp8: stale deblk_buf_size in cedrus_vp8_start() -- commit 2e3e9674b0e42d966116e3aba1d357709db8157f Author: Jernej Skrabec <jernej.skrabec@gmail.com> staging: media: cedrus: vp8: support frames wider than 2048 pixels This commit adds support for decoding VP8 frames wider than 2048 pixels by allocating the deblocking and intra prediction row buffers in DRAM when they no longer fit in internal SRAM. > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > index 6b00efa77c223..954c0ceb98ed2 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c [ ... ] > @@ -849,7 +863,44 @@ static int cedrus_vp8_start(struct cedrus_ctx *ctx) > memcpy(&ctx->codec.vp8.entropy_probs_buf[2048], > prob_table_init, sizeof(prob_table_init)); > > + /* > + * Above 2048 pixels the deblocking and intra prediction row buffers > + * no longer fit into the internal SRAM. The vendor library sizes the > + * deblocking buffer as 24 bytes per (32 aligned) column. > + */ > + if (ctx->src_fmt.width > 2048) { > + ctx->codec.vp8.deblk_buf_size = > + ALIGN(ctx->src_fmt.width, 32) * 24; > + ctx->codec.vp8.deblk_buf = > + dma_alloc_attrs(dev->dev, ctx->codec.vp8.deblk_buf_size, > + &ctx->codec.vp8.deblk_buf_dma, > + GFP_KERNEL, DMA_ATTR_NO_KERNEL_MAPPING); > + if (!ctx->codec.vp8.deblk_buf) > + goto err_probs; > + > + ctx->codec.vp8.intra_pred_buf_size = > + ALIGN(ctx->src_fmt.width, 64) * 5 * 2; > + ctx->codec.vp8.intra_pred_buf = > + dma_alloc_attrs(dev->dev, > + ctx->codec.vp8.intra_pred_buf_size, > + &ctx->codec.vp8.intra_pred_buf_dma, > + GFP_KERNEL, DMA_ATTR_NO_KERNEL_MAPPING); > + if (!ctx->codec.vp8.intra_pred_buf) > + goto err_deblk; > + } > + > return 0; > + > +err_deblk: > + dma_free_attrs(dev->dev, ctx->codec.vp8.deblk_buf_size, > + ctx->codec.vp8.deblk_buf, ctx->codec.vp8.deblk_buf_dma, > + DMA_ATTR_NO_KERNEL_MAPPING); > + ctx->codec.vp8.deblk_buf_size = 0; > +err_probs: > + dma_free_coherent(dev->dev, CEDRUS_ENTROPY_PROBS_SIZE, > + ctx->codec.vp8.entropy_probs_buf, > + ctx->codec.vp8.entropy_probs_buf_dma); > + return -ENOMEM; > } [Severity: High] Can ctx->codec.vp8.deblk_buf_size remain non-zero in cedrus_vp8_start() when the DRAM buffers have not been allocated? In cedrus_vp8_start(), ctx->codec.vp8.deblk_buf_size is set before calling dma_alloc_attrs() for ctx->codec.vp8.deblk_buf. If that allocation fails, execution jumps to err_probs, which skips resetting deblk_buf_size to 0 (and similarly, err_deblk does not reset intra_pred_buf_size to 0 when the second allocation fails). If userspace then changes the OUTPUT format width to 2048 or less and starts streaming again on the same context, cedrus_vp8_start() skips the width > 2048 block and succeeds with ctx->codec.vp8.deblk_buf_size still non-zero. Similarly, because ctx->codec is a union in struct cedrus_ctx and cedrus_vp8_start() does not clear deblk_buf_size when width <= 2048, switching a context from another codec (such as H.264) to VP8 with width <= 2048 can leave stale non-zero values in ctx->codec.vp8. In both cases, cedrus_vp8_setup() and cedrus_vp8_stop() check if (ctx->codec.vp8.deblk_buf_size), which will program VE_DBLK_DRAM_BUF_ADDR and VE_INTRAPRED_DRAM_BUF_ADDR with unallocated or stale DMA addresses and call dma_free_attrs() on unallocated or stale pointers when stopping. Should cedrus_vp8_start() explicitly initialize deblk_buf_size and intra_pred_buf_size to 0 (or reset deblk_buf_size under err_probs and intra_pred_buf_size under err_deblk)?
Le lundi 02 novembre 2026 à 18:02 +0100, Jernej Skrabec a écrit : > The hardware decodes whatever picture size the SPS describes. An SPS > beyond CEDRUS_MAX_WIDTH/HEIGHT, or beyond the capture buffers once they > are allocated, makes the hardware overrun memory and hang. On H616, the > JCT-VC PICSIZE_A..D streams (1056x8440, 8440x1056, 528x4216 and > 4216x528) leave the hardware wedged, so that every following job times > out until reboot. > > Validate the SPS picture size in try_ctrl. Move the size limits to > cedrus_video.h for that. > > Fixes: 6eb9b758e307 ("media: cedrus: Add H264 decoding support") > Fixes: 86caab29da78 ("media: cedrus: Add HEVC/H.265 decoding support") > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> > --- > drivers/staging/media/sunxi/cedrus/cedrus.c | 40 ++++++++++++++++++- > .../staging/media/sunxi/cedrus/cedrus_video.c | 5 --- > .../staging/media/sunxi/cedrus/cedrus_video.h | 5 +++ > 3 files changed, 44 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c > index c3331b4f3f02..45deebddb630 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c > @@ -28,10 +28,38 @@ > #include "cedrus_dec.h" > #include "cedrus_hw.h" > > +/* > + * The hardware decodes whatever picture size the bitstream headers describe. > + * Reject sizes beyond the hardware limits, or beyond the capture buffers once > + * they are allocated, instead of letting the hardware overrun memory and hang. > + */ > +static int cedrus_check_pic_size(struct cedrus_ctx *ctx, u32 width, u32 height) > +{ > + struct vb2_queue *vq; > + > + if (width > CEDRUS_MAX_WIDTH || height > CEDRUS_MAX_HEIGHT) > + return -EINVAL; > + > + /* > + * The hardware decodes whole 16x16 macroblocks, and all capture > + * formats pad the buffers to at least 16 pixels in both directions. > + */ > + vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); > + if (vb2_is_busy(vq) && > + (width > ALIGN(ctx->src_fmt.width, 16) || > + height > ALIGN(ctx->src_fmt.height, 16))) > + return -EINVAL; If my memory is correct, Hans rejected this kind of construct in try_ctrl, because if you are only doing try() it shouldn't fail like this. Instead we can validate in the real s_ctrl, but I believe the downside is that it makes the error asynchronous when a request is used (perhaps that's actually wanted ?) Nicolas > + > + return 0; > +} > + > static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl) > { > + struct cedrus_ctx *ctx = container_of(ctrl->handler, struct cedrus_ctx, hdl); > + > if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) { > const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps; > + u32 height; > > if (sps->chroma_format_idc != 1) > /* Only 4:2:0 is supported */ > @@ -42,9 +70,15 @@ static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl) > if (sps->bit_depth_luma_minus8 != 0) > /* Only 8-bit is supported */ > return -EINVAL; > + height = (sps->pic_height_in_map_units_minus1 + 1) * 16; > + if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY)) > + height *= 2; > + if (cedrus_check_pic_size(ctx, > + (sps->pic_width_in_mbs_minus1 + 1) * 16, > + height)) > + return -EINVAL; > } else if (ctrl->id == V4L2_CID_STATELESS_HEVC_SPS) { > const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; > - struct cedrus_ctx *ctx = container_of(ctrl->handler, struct cedrus_ctx, hdl); > unsigned int bit_depth, max_depth; > struct vb2_queue *vq; > > @@ -52,6 +86,10 @@ static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl) > /* Only 4:2:0 is supported */ > return -EINVAL; > > + if (cedrus_check_pic_size(ctx, sps->pic_width_in_luma_samples, > + sps->pic_height_in_luma_samples)) > + return -EINVAL; > + > bit_depth = max(sps->bit_depth_luma_minus8, > sps->bit_depth_chroma_minus8) + 8; > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c > index adc7f255d7cf..2521315abdb7 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c > @@ -29,11 +29,6 @@ > #define CEDRUS_DECODE_SRC BIT(0) > #define CEDRUS_DECODE_DST BIT(1) > > -#define CEDRUS_MIN_WIDTH 16U > -#define CEDRUS_MIN_HEIGHT 16U > -#define CEDRUS_MAX_WIDTH 4096U > -#define CEDRUS_MAX_HEIGHT 2304U > - > static struct cedrus_format cedrus_formats[] = { > { > .pixelformat = V4L2_PIX_FMT_MPEG2_SLICE, > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.h b/drivers/staging/media/sunxi/cedrus/cedrus_video.h > index 8e1afc16a6a1..367e52158f01 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.h > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.h > @@ -22,6 +22,11 @@ struct cedrus_format { > unsigned int capabilities; > }; > > +#define CEDRUS_MIN_WIDTH 16U > +#define CEDRUS_MIN_HEIGHT 16U > +#define CEDRUS_MAX_WIDTH 4096U > +#define CEDRUS_MAX_HEIGHT 2304U > + > extern const struct v4l2_ioctl_ops cedrus_ioctl_ops; > > int cedrus_queue_init(void *priv, struct vb2_queue *src_vq,
Le lundi 02 novembre 2026 à 18:02 +0100, Jernej Skrabec a écrit : > A field picture covers only half of the macroblock rows of a frame, but > the driver programs the coded and the boundary size of the whole frame > for it, as for a frame picture. > > Program the height of a field for field pictures, like the vendor > library does. > > Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver") > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> > --- > drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > index 10e98f08aafc..ca66a3c6b830 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_mpeg2.c > @@ -58,6 +58,7 @@ static int cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) > struct vb2_queue *vq; > const u8 *matrix; > unsigned int i; > + bool field; > u32 reg; > > seq = run->mpeg2.sequence; > @@ -108,13 +109,21 @@ static int cedrus_mpeg2_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) > > /* Set frame dimensions. */ > > + /* > + * Field pictures cover half of the frame's macroblock rows; the > + * vendor library halves both the coded and the boundary height. > + */ > + field = pic->picture_structure != V4L2_MPEG2_PIC_FRAME; > + > reg = VE_DEC_MPEG_PICCODEDSIZE_WIDTH(seq->horizontal_size); > - reg |= VE_DEC_MPEG_PICCODEDSIZE_HEIGHT(seq->vertical_size); > + reg |= VE_DEC_MPEG_PICCODEDSIZE_HEIGHT(field ? > + ALIGN(seq->vertical_size, 32) / 2 : seq->vertical_size); > > cedrus_write(dev, VE_DEC_MPEG_PICCODEDSIZE, reg); > > reg = VE_DEC_MPEG_PICBOUNDSIZE_WIDTH(ctx->src_fmt.width); > - reg |= VE_DEC_MPEG_PICBOUNDSIZE_HEIGHT(ctx->src_fmt.height); > + reg |= VE_DEC_MPEG_PICBOUNDSIZE_HEIGHT(field ? ctx->src_fmt.height / 2 : > + ctx->src_fmt.height); I'm not entirely sure, but I see: fsize->stepwise.step_height = 1; But I don't think interlaced video can have odd height in the first place. But it also have an implication here as you are not rounding up to a multiple of 2. Not sure what is the proper fix, but I have this impression something is missing. Nicolas > > cedrus_write(dev, VE_DEC_MPEG_PICBOUNDSIZE, reg); >
Hi, Le lundi 02 novembre 2026 à 18:03 +0100, Jernej Skrabec a écrit : > A VP8 key frame can change the frame size. If userspace doesn't > reallocate the capture buffers, the hardware writes and reads past the > buffers, which shows up as IOMMU page faults and decode timeouts. > > Check the frame size in try_ctrl, like for the H.264 and HEVC SPS. > > Fixes: 3c39a16d30d8 ("media: cedrus: Add support for VP8 decoding") > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> > --- > drivers/staging/media/sunxi/cedrus/cedrus.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c > index 45deebddb630..756243795de8 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c > @@ -77,6 +77,11 @@ static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl) > (sps->pic_width_in_mbs_minus1 + 1) * 16, > height)) > return -EINVAL; > + } else if (ctrl->id == V4L2_CID_STATELESS_VP8_FRAME) { > + const struct v4l2_ctrl_vp8_frame *frame = ctrl->p_new.p_vp8_frame; > + > + if (cedrus_check_pic_size(ctx, frame->width, frame->height)) > + return -EINVAL; This is affected by my previous comment, let's discuss over the other report first. Nicolas > } else if (ctrl->id == V4L2_CID_STATELESS_HEVC_SPS) { > const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; > unsigned int bit_depth, max_depth; > @@ -270,6 +275,7 @@ static const struct cedrus_control cedrus_controls[] = { > { > .cfg = { > .id = V4L2_CID_STATELESS_VP8_FRAME, > + .ops = &cedrus_ctrl_ops, > }, > .capabilities = CEDRUS_CAPABILITY_VP8_DEC, > },
Hi, Le lundi 02 novembre 2026 à 18:03 +0100, Jernej Skrabec a écrit : > The driver allocates the VP8 probability table with 0x2400 bytes, which > is the size the old Allwinner A10 library uses. All newer vendor > libraries allocate 0x5400 bytes and never write the area past 0x11b0 > from the CPU. The hardware uses that area as scratch space, most likely > for the segment map, and its usage grows with the frame size: a > 3840x2160 stream makes the hardware access memory past 0x2400 and > causes IOMMU page faults. > > Allocate the table with 0x5400 bytes, like the vendor libraries do. > > Fixes: 3c39a16d30d8 ("media: cedrus: Add support for VP8 decoding") > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> > --- > drivers/staging/media/sunxi/cedrus/cedrus_vp8.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > index 969677a3bbf9..6b00efa77c22 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > @@ -25,7 +25,7 @@ > #include "cedrus_hw.h" > #include "cedrus_regs.h" > > -#define CEDRUS_ENTROPY_PROBS_SIZE 0x2400 > +#define CEDRUS_ENTROPY_PROBS_SIZE 0x5400 > #define VP8_PROB_HALF 128 > #define QUANT_DELTA_COUNT 5 >
Le lundi 02 novembre 2026 à 18:03 +0100, Jernej Skrabec a écrit : > Above 2048 pixels, the deblocking and intra prediction row buffers don't > fit into the internal SRAM anymore. Put them into DRAM like H.264 does. > The vendor library sizes the deblocking buffer as 24 bytes per column. > > Tested on H616 with 2560x1440 and 3840x2160 libvpx streams, which are > bit-exact with the FFmpeg software decoder. > > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> > --- > drivers/staging/media/sunxi/cedrus/cedrus.h | 7 ++ > .../staging/media/sunxi/cedrus/cedrus_vp8.c | 64 +++++++++++++++++++ > 2 files changed, 71 insertions(+) > > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h > index d28fe91562d1..ca4efa9302fc 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus.h > +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h > @@ -156,6 +156,13 @@ struct cedrus_ctx { > > u8 *entropy_probs_buf; > dma_addr_t entropy_probs_buf_dma; > + > + void *deblk_buf; > + dma_addr_t deblk_buf_dma; > + ssize_t deblk_buf_size; > + void *intra_pred_buf; > + dma_addr_t intra_pred_buf_dma; > + ssize_t intra_pred_buf_size; > } vp8; > } codec; > }; > diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > index 6b00efa77c22..954c0ceb98ed 100644 > --- a/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > +++ b/drivers/staging/media/sunxi/cedrus/cedrus_vp8.c > @@ -666,6 +666,20 @@ static int cedrus_vp8_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) > > cedrus_write(dev, VE_H264_CTRL, VE_H264_CTRL_VP8); > > + if (ctx->codec.vp8.deblk_buf_size) { > + cedrus_write(dev, VE_BUF_CTRL, > + VE_BUF_CTRL_INTRAPRED_MIXED_RAM | > + VE_BUF_CTRL_DBLK_MIXED_RAM); > + cedrus_write(dev, VE_DBLK_DRAM_BUF_ADDR, > + ctx->codec.vp8.deblk_buf_dma); > + cedrus_write(dev, VE_INTRAPRED_DRAM_BUF_ADDR, > + ctx->codec.vp8.intra_pred_buf_dma); > + } else { > + cedrus_write(dev, VE_BUF_CTRL, > + VE_BUF_CTRL_INTRAPRED_INT_SRAM | > + VE_BUF_CTRL_DBLK_INT_SRAM); > + } > + > cedrus_vp8_update_probs(slice, ctx->codec.vp8.entropy_probs_buf); > > reg = slice->first_part_size * 8; > @@ -849,7 +863,44 @@ static int cedrus_vp8_start(struct cedrus_ctx *ctx) > memcpy(&ctx->codec.vp8.entropy_probs_buf[2048], > prob_table_init, sizeof(prob_table_init)); > > + /* > + * Above 2048 pixels the deblocking and intra prediction row buffers > + * no longer fit into the internal SRAM. The vendor library sizes the > + * deblocking buffer as 24 bytes per (32 aligned) column. > + */ > + if (ctx->src_fmt.width > 2048) { > + ctx->codec.vp8.deblk_buf_size = > + ALIGN(ctx->src_fmt.width, 32) * 24; > + ctx->codec.vp8.deblk_buf = > + dma_alloc_attrs(dev->dev, ctx->codec.vp8.deblk_buf_size, > + &ctx->codec.vp8.deblk_buf_dma, > + GFP_KERNEL, DMA_ATTR_NO_KERNEL_MAPPING); > + if (!ctx->codec.vp8.deblk_buf) > + goto err_probs; > + > + ctx->codec.vp8.intra_pred_buf_size = > + ALIGN(ctx->src_fmt.width, 64) * 5 * 2; > + ctx->codec.vp8.intra_pred_buf = > + dma_alloc_attrs(dev->dev, > + ctx->codec.vp8.intra_pred_buf_size, > + &ctx->codec.vp8.intra_pred_buf_dma, > + GFP_KERNEL, DMA_ATTR_NO_KERNEL_MAPPING); > + if (!ctx->codec.vp8.intra_pred_buf) > + goto err_deblk; > + } > + > return 0; > + > +err_deblk: > + dma_free_attrs(dev->dev, ctx->codec.vp8.deblk_buf_size, > + ctx->codec.vp8.deblk_buf, ctx->codec.vp8.deblk_buf_dma, > + DMA_ATTR_NO_KERNEL_MAPPING); > + ctx->codec.vp8.deblk_buf_size = 0; > +err_probs: > + dma_free_coherent(dev->dev, CEDRUS_ENTROPY_PROBS_SIZE, > + ctx->codec.vp8.entropy_probs_buf, > + ctx->codec.vp8.entropy_probs_buf_dma); > + return -ENOMEM; > } > > static void cedrus_vp8_stop(struct cedrus_ctx *ctx) > @@ -861,6 +912,19 @@ static void cedrus_vp8_stop(struct cedrus_ctx *ctx) > dma_free_coherent(dev->dev, CEDRUS_ENTROPY_PROBS_SIZE, > ctx->codec.vp8.entropy_probs_buf, > ctx->codec.vp8.entropy_probs_buf_dma); > + > + if (ctx->codec.vp8.deblk_buf_size) { > + dma_free_attrs(dev->dev, ctx->codec.vp8.deblk_buf_size, > + ctx->codec.vp8.deblk_buf, > + ctx->codec.vp8.deblk_buf_dma, > + DMA_ATTR_NO_KERNEL_MAPPING); > + dma_free_attrs(dev->dev, ctx->codec.vp8.intra_pred_buf_size, > + ctx->codec.vp8.intra_pred_buf, > + ctx->codec.vp8.intra_pred_buf_dma, > + DMA_ATTR_NO_KERNEL_MAPPING); > + ctx->codec.vp8.deblk_buf_size = 0; > + ctx->codec.vp8.intra_pred_buf_size = 0; > + } > } > > static void cedrus_vp8_trigger(struct cedrus_ctx *ctx)