From mboxrd@z Thu Jan 1 00:00:00 1970 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 9E662C43334 for ; Mon, 11 Jul 2022 21:32:25 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7nzZJQpaJoHNevIOn0/JxbuAxkRz759YW5LmAQAz02U=; b=0z8hP77DVEvQa+ N12NW+6d5+nVQBbYr+8dRc0U7ZTlgQ/xYetS3xg5evj3/Az6ujxsFa/sh9PhAN0CscLC5AfPV6HZX VNvidW8EfaK7CnmsSXq68Ft3tsMRDEd8S4AWqiOEtRvf9gBzYDQC1lZOIejYmNHpq/7E9TAG0RS3M 9ViJnabNzCDDXcq/sCtlK7poIeyJTSc6VH+Usz8IZVfcTti7SYViKjg6Mb7+g1eUUXi/QyNU+rSHv jcFb6ZPwG4WJ/0+UbDoD0EGrcEor7GnNNciH+uvUXo4C/SI0eZ20ZCZxQscOCWAiro65elBv13lmF dQ+zfNkvWp9xCVee6IVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oB0zz-004wOT-CG; Mon, 11 Jul 2022 21:31:23 +0000 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oB0zv-004wMc-Qn for linux-arm-kernel@lists.infradead.org; Mon, 11 Jul 2022 21:31:21 +0000 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-fe023ab520so8209170fac.10 for ; Mon, 11 Jul 2022 14:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7n3w5NrYm/9yYQ9V3SfFW9a8qDSCjRoKWMuBQnXHsKY=; b=QF2Xg2MtsK/2ZJ5WRBoMc1k5dYw3waxhgvcwNXEs49H04i1zrRJ+XGgvXMp2a3/dBT Fj1lxulUt3GWzoOVkCuz5iym2Y/voMfIVC3x25c0CZjmU4zGPUSEM0hgN3bps3Hc1SeL dApGt5NcFK7DGw7ubR2HMVGx3DcAT5SRMKIWM3W9SeyYJKOSlkeFGd+hDKh46u3O7BWV 8QE7GMo6nazUqPpwO1rF9zWL2bcv+Hvb5Y2pfxZzaugVbZSMpo8wxmJUQ5Yzkz7WR29F +HE4WZT6U9+R1L7CrOLKRi6wFUIExrp1vfbHOLeDeOk0JAw+OOfHwkRLc2kXPKstqqpY 9xCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7n3w5NrYm/9yYQ9V3SfFW9a8qDSCjRoKWMuBQnXHsKY=; b=4Wwd+B+XjJCFFXi4qgrZ+U4VIRj+MeIgIV8+3JD20u3BjNtEc3F2atmCB/bcvIn7vH VgbXSNj+0jAP/xFkpv+a0k0+UvQJEHvBPmp62FqUy3tu2R7WL3RUqVBoWGSO4YyNuOG2 9nGsouSnAXeHSPaNoXxqdH8hORsSRxQzRM15bq76Uh3OEuY+XRwgzRfq8vCWBWRaoezM 09QA9Y3jr0V3a8aA2QP0JgoF6S684GfCo7etdOZRHE+6Njlp7RSlLlFmClsmIzA9RooN umCGH96o9SC2fC9fWAXJRs8tiVm0Zz3cZUXmle62yjfs1pVKYFnmKT6+p83xGdtQ1S4o T/uQ== X-Gm-Message-State: AJIora/dCFOaQDMdzQwokv9aT5ZNhaokmryeiQDezNFTvTh2MqmhG3vk va2gkHCNgLwltKVX6EOe5SBL9A== X-Google-Smtp-Source: AGRyM1uCR2BXqc5p8Qeh61l5nCwoRNGtIlvjIbxcjNc7ZgDeSlXAzU+yt0Alh5FtkTzmQL4KovhBtQ== X-Received: by 2002:a05:6870:204c:b0:101:6275:67de with SMTP id l12-20020a056870204c00b00101627567demr196501oad.101.1657575077220; Mon, 11 Jul 2022 14:31:17 -0700 (PDT) Received: from eze-laptop ([190.190.187.68]) by smtp.gmail.com with ESMTPSA id t19-20020a05683022f300b0061c4ceeac81sm1535097otc.49.2022.07.11.14.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 14:31:16 -0700 (PDT) Date: Mon, 11 Jul 2022 18:31:11 -0300 From: Ezequiel Garcia To: Jernej Skrabec Cc: mripard@kernel.org, paul.kocialkowski@bootlin.com, wens@csie.org, samuel@sholland.org, 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 Subject: Re: [PATCH 5/7] media: cedrus: h265: Add a couple of error checks Message-ID: References: <20220620175517.648767-1-jernej.skrabec@gmail.com> <20220620175517.648767-6-jernej.skrabec@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220620175517.648767-6-jernej.skrabec@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220711_143119_886804_902472DC X-CRM114-Status: GOOD ( 22.77 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 20, 2022 at 07:55:15PM +0200, Jernej Skrabec wrote: > 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 > --- > 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 Now that you've allowed setup to fail, I would suggest to have some documentation/comments on struct cedrus_dec_ops, to set the expectation/rules for each ops, including the call paths for each operation, which of them are allowed to sleep, etc. > @@ -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; > + AFAICS, cedrus_h265_setup is called from .device_run. We've been discussing control validation before, and I think the ideal place to do that is v4l2_ctrl_ops.s_ctrl, if that's at all possible. Driver's mem2mem device_run are executed in the context of a work_struct and the failure won't really get reported up the stack. > 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; > + Maybe this is something to check at cedrus_buf_prepare(), when the buffer is queued? Thanks, Ezequiel > for (count = 0; count < 8; count++) > if (*padding & (1 << count)) > break; > -- > 2.36.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel