[v8,07/53] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20230927153558.159278-8-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2723208vqu; Wed, 27 Sep 2023 08:52:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEG2FBrT/b0+aRsWcoNIjPS23Z9A8H5O5sg+vFxNiDYVEqvQGNUy6O+Irl02KLi9a4XAf0y X-Received: by 2002:a05:6a00:2382:b0:68f:cc47:fcc8 with SMTP id f2-20020a056a00238200b0068fcc47fcc8mr2659161pfc.14.1695829946716; Wed, 27 Sep 2023 08:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695829946; cv=none; d=google.com; s=arc-20160816; b=k0VHC27Dy2BSNCeOVaq5HgtAcrdYncBoEYMEMPthBZr61m1GqSPBY358Jm/DcDXlOo qP+D6SBRknWlFI5G2nRWoRvS7yjrKP0U5aCawPBFRZqEe6m4iMW2/Q9Brp0Gm7SNZ5DM 1Z06OTv9cSxClxg/rK8KI8H0xgicBNIooBmFoj5RHF+qUa7Lub7EHYmV8KT5apB5f+3A syzS1SWFiop0gTSKoe7JV8t0rtgG1toPdPeiwbl3Cbtpq+o36v6X0eO47rhcnztLz58T YAL9IQj9yfWLzyQPVW3qrL0H4ljgWACsxHmEkzS8lDsJ5R02h/d8rj8oDfbSQBRQux5h Y/pA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oHNryKbCJeblfYmngcGtoYS+YQQ+1KvLxsjalykbByU=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=A5xO0iAn+BWi/ktdRx8XtVUzFjkkqsfME1qe4FD4KzSZIuxl5XYyzWYsE6sW5wtPlE GqZ38JQ3OA0MIEXM1Q0ZLP7VzyGKGy4e7vTE8V4In/0F5FmdrjRQaffP/xmp7IfjpPNC 8B8dCEc6Hm7O4Sd71tmZJAxfzWmjjmfGPM9ikgSmrl8Ptq2hk9HBmpvvSc3XIuyp+SHV Z8puk6wHcKW6tA6TWHt7MxvWmsQ4sww9ANgULw3ZXlUqFLVQG2M6o14CJA5pzvmznkij csONBojENs2HjzfOxqP3ZS9KC5Qimt+3PtyshL38Ew9TQv1F3LQsw+A0vOaMBSLLLBC4 E7fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KMDgUwon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id y18-20020a056a00181200b00690a75a318asi17690342pfa.67.2023.09.27.08.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 08:52:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=KMDgUwon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A6C62801E5F9; Wed, 27 Sep 2023 08:36:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232607AbjI0Pgn (ORCPT <rfc822;ruipengqi7@gmail.com> + 19 others); Wed, 27 Sep 2023 11:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232519AbjI0PgP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 27 Sep 2023 11:36:15 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BC39136; Wed, 27 Sep 2023 08:36:13 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:672:46bd:3ec7:6cdf]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2C8F06607332; Wed, 27 Sep 2023 16:36:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695828970; bh=dORnTzB2rXmsaHgnhN9KRI5xHQJEBU6mRdZelnGjotA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMDgUwonf2lW5eRH7lA4RKRlpDlHdXq0Q2LfIFDyLzsDKPFhC4b24/93gkehWt8AJ TJ1MqsMNw22xNF8lNLdkA3vXHkFdn2gn0FGaaQixTVA8pGu8A9ibqCSCQn8Z8HG+7D 0vKDgzPINWPePIZOn2sPIM9JCrEu5Ncf6ih970cu9RKs9CtixgfhBcX8RXt92+w6AR /FsIUxGDx4QHv+LVbX/Fhxi6vh7XvU62/amHu9w3cLeZEiW24CfFFU/1zYoxI3lP/h ysVEnog4uRlqd6Fsl913z+44m1cNjkx3sDKpKC8y9GawmiC54ToLTvBq0fAWY14eKN XedA+BZtLsntA== From: Benjamin Gaignard <benjamin.gaignard@collabora.com> To: mchehab@kernel.org, tfiga@chromium.org, m.szyprowski@samsung.com, ming.qian@nxp.com, ezequiel@vanguardiasur.com.ar, p.zabel@pengutronix.de, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, kernel@collabora.com, Benjamin Gaignard <benjamin.gaignard@collabora.com> Subject: [PATCH v8 07/53] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array Date: Wed, 27 Sep 2023 17:35:12 +0200 Message-Id: <20230927153558.159278-8-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927153558.159278-1-benjamin.gaignard@collabora.com> References: <20230927153558.159278-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 08:36:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778206582079978218 X-GMAIL-MSGID: 1778206582079978218 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Sept. 27, 2023, 3:35 p.m. UTC
Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array.
After each call to vb2_get_buffer() we need to be sure that we get
a valid pointer so check the return value of all of them.
Remove index range test since it is done by vb2_get_buffer().
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
drivers/media/platform/st/sti/hva/hva-v4l2.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/st/sti/hva/hva-v4l2.c b/drivers/media/platform/st/sti/hva/hva-v4l2.c index 3a848ca32a0e..cfe83e9dc01b 100644 --- a/drivers/media/platform/st/sti/hva/hva-v4l2.c +++ b/drivers/media/platform/st/sti/hva/hva-v4l2.c @@ -569,14 +569,11 @@ static int hva_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) struct vb2_buffer *vb2_buf; vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, buf->type); - - if (buf->index >= vq->num_buffers) { - dev_dbg(dev, "%s buffer index %d out of range (%d)\n", - ctx->name, buf->index, vq->num_buffers); + vb2_buf = vb2_get_buffer(vq, buf->index); + if (!vb2_buf) { + dev_dbg(dev, "%s buffer index %d not found\n", ctx->name, buf->index); return -EINVAL; } - - vb2_buf = vb2_get_buffer(vq, buf->index); stream = to_hva_stream(to_vb2_v4l2_buffer(vb2_buf)); stream->bytesused = buf->bytesused; }