From patchwork Mon Jun 20 17:55:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12888012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BA4ACCA47F for ; Mon, 20 Jun 2022 17:58:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/OX7lvkxdSwjoLkMW1uI1Cr2BtRdxpgN7jBFiLo4TDU=; b=rRmqAvqgn7T4Aw fsJmvQojsaS1BxQ7bJYjbq0W8YHeqC+LCHPTCLkjgNO+ziW+yTqtDueqjqsydBHP8nNL4lAcbxmMr 5dYu0Tkfq4Q3rxsTmN2ldxNUJjXsuYdMhIVxwQhAr3JvHYbjlFO/srtgF0EC09cqT+27/5hqmKTx2 jqIqow2Hnoojhz6DoKnG40PgPE2hV91ZB/+KKUfxIOT/r3CgOe1gA+5KhSrsmaifU6aU6tr7yLSIF Z/JGUHC+4i4Y/0mBrAF9mVMhGP1Sp2w+vHvClXoiWmpr9YE5uoRYUx4GXbSACN0sEfnqWU/BsAewK iC/Hb8lBRYpYgfud2Fkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3LeB-001i1H-Oy; Mon, 20 Jun 2022 17:57:12 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3Lcf-001hS7-Vm for linux-arm-kernel@lists.infradead.org; Mon, 20 Jun 2022 17:55:40 +0000 Received: by mail-wr1-x42a.google.com with SMTP id k22so9252793wrd.6 for ; Mon, 20 Jun 2022 10:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jAE816XO6VphxEuAFtyQWbCCtJPUMXYblVqNrF0iAD0=; b=EjeBvCJQTY+EP5xtkOeq06z4jqZO6QnTRjA0gabAPlGhSRDpNsrn1q+fWqg6VbQZCv D5JS7lnPYgCf+q8DOQpXVljhTT1WJMU6a4hdMh+2OdrTyWdrzFTo8GEhr936m4L10koo qdxV//MmmPL5IjwdwC06oF3I4YghZlM2Nlnp3jAi9/xDA21fucQrDANY51ICxGaMqFE5 9lJmKXFfVr6JpVAxp1scG4VTtwKTroTUNk2T8qAmchLeVCqslJNw2U/vf4KiB60BeOrk pHsOn9RErSosIyP1azI/AUjFu6UgHfrweLf+d5yYlAI1ZbCz9pwH2q4quxKSXdzq+JAe WR3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jAE816XO6VphxEuAFtyQWbCCtJPUMXYblVqNrF0iAD0=; b=plJYtk8su9W08IMhLnSzxkiPNfTGBGIRnno4tL9NOPoe8WhU1c2LYlguD1ziiFfDWM WaXCo60Z1KNg5LhIDKOTEgvE8jXtY6IXa0GAvsbEId7dT72ob3EcOnEc+69AqV4kpFWD B9u8+4qmyTJdFXimSI8gwxA0bXVdrK5fY237l3cvcoCwypeK7FYmgRp00H4bkSjkbBjR vja+/ZhxB6Wt4b/YCBh5q6JtVGzTdbJfcYF1sVL4sRg7PQt9paU9prb/HJy0aq2OQhmv kIG99VdE3ht3tUXcy3U/Vc4ORIVcu5G04MwixkZEP1tYV1RD1sKtL+FcJGxHCmHzPFAB CREA== X-Gm-Message-State: AJIora/oR7/Ae4x6XcGqk5Nc5wevzRTv5NGK4Q7oR4y+qRe7mpHgaSsK BZC/woLYzuaSp+4EN2eECSU= X-Google-Smtp-Source: AGRyM1uzYFeRmPExq2bdZPq2d3BODGUt8CJhpH6WPmqRMAMe3MzAwr61mxnFobDHbuDcKZ/xOE15MA== X-Received: by 2002:adf:f7c7:0:b0:21b:9452:e8fe with SMTP id a7-20020adff7c7000000b0021b9452e8femr2386433wrq.640.1655747735690; Mon, 20 Jun 2022 10:55:35 -0700 (PDT) Received: from kista.localdomain (213-161-3-76.dynamic.telemach.net. [213.161.3.76]) by smtp.gmail.com with ESMTPSA id 184-20020a1c02c1000000b0039db31f6372sm19620752wmc.2.2022.06.20.10.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 10:55:35 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com, wens@csie.org, samuel@sholland.org Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, 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 Subject: [PATCH 5/7] media: cedrus: h265: Add a couple of error checks Date: Mon, 20 Jun 2022 19:55:15 +0200 Message-Id: <20220620175517.648767-6-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620175517.648767-1-jernej.skrabec@gmail.com> References: <20220620175517.648767-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220620_105538_139130_4FDD072A X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that we have infrastructure for reporting errors, let's add two checks, which will make sure slice can be actually decoded. Signed-off-by: Jernej Skrabec Reviewed-by: Ezequiel Garcia --- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index cfde4ccf6011..99020b9f9ff8 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -435,9 +435,17 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) * instead of start of slice data. Padding is 8 bits at most (one bit set to 1 and * at most seven bits set to 0), so we have to inspect only one byte before slice data. */ + + if (slice_params->data_byte_offset == 0) + return -EOPNOTSUPP; + padding = (u8 *)vb2_plane_vaddr(&run->src->vb2_buf, 0) + slice_params->data_byte_offset - 1; + /* at least one bit must be set in that byte */ + if (*padding == 0) + return -EINVAL; + for (count = 0; count < 8; count++) if (*padding & (1 << count)) break;