[v12,14/56] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231017144756.34719-15-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4188310vqb; Tue, 17 Oct 2023 07:51:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8eNXUmoQqv+H/mZ9PHRuYHg/wBGKZ9vQP1LNqGNn7XJtNnJylBoWIXE3sRg4hOr+oe8V9 X-Received: by 2002:a05:6359:1b8f:b0:166:d9b8:4de6 with SMTP id ur15-20020a0563591b8f00b00166d9b84de6mr2111554rwb.1.1697554283775; Tue, 17 Oct 2023 07:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697554283; cv=none; d=google.com; s=arc-20160816; b=X5L1206ybqj4/uvX7bijwea8xRooe7G4Jk9/rCq5KCCM1ONg4VqX8TOsP/l8clszul 3JUE9gjyWnCBbFU1N2Z6IPWjWAXM0A63P12CGVcd7/VIQdrr2Iu3iZhzxl/zoNAAas65 Jm/MlVY+b/TEmex83xTaxAnFaWO7mEOk0lw3ny2duITut6o+nAjLdAI6UYpW/jONB92P /LUI2vjb+F1IdccjFw/0EYkhIjK1xRlrk5ghf2fHQy77rmUskWwx4PeFYpA4F0Ii4cg7 m6rMjFrcDCA0IDYK2S7Kmdgm5yDGCyCq3GYxiQuhpkRk7xJ9p/znTG7ggGvfJtCKFNzl Tinw== 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=ARXOSBKGUUPDwevHrxoh+LOz0HRWiSJssojf7QO4Re0=; fh=NPTCYP6kV89VhZcTyqjnuKz2OW5UZUbu4oezKHT17AA=; b=ABkN3fj6Y7ih9ooKzw6diZfoIL6guSxpQbK9dFGEZT7LwIpMAK2xrC6hOVYvgITxdA zfRV8h/4Zv08nbH4114vE/WgkyIZlxiB5RBtYr2WAl450KNIhw3Wn2JDYj0d498HZGO2 26sKkZ+hTVvWyB3S0uYo8d/X38OWzoJsx5zq1I8Dz19BJB9CSScF4o1BYLTfrLmfeXek YLQDRzjDhFvrHhmoDq67NXD3NL5I9ylu5/eF/pwqJRPNklECToBbKYH0Z7plQyxY/Mre /aCxSqm2ycYIyGHke7i3N+QZ8rVi4z+jyfjJG6a+oXvsRJhyNaRL/j0b908ai5YOuqUD I8Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=OmzphVl3; 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 j63-20020a638042000000b005b7e6ff6c01si1866128pgd.677.2023.10.17.07.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:51:23 -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=OmzphVl3; 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 8A15E8066477; Tue, 17 Oct 2023 07:50:42 -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 S1344406AbjJQOs6 (ORCPT <rfc822;hjfbswb@gmail.com> + 20 others); Tue, 17 Oct 2023 10:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344157AbjJQOsO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 17 Oct 2023 10:48:14 -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 17178BA; Tue, 17 Oct 2023 07:48:12 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7205:da49:a7e8:59f8]) (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 72CD86607348; Tue, 17 Oct 2023 15:48:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697554090; bh=6OByUfiYmown+37pp4jYIRU8BDesYsod95qP0wK3edE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OmzphVl3bt5nyIgREflOGALqjd8pI5dA7oiUI33s7NwG+gVcvIyBMnlAewQOHU+LI QOU0FQUOeBwTLq+gOSVFVcOHSLTKtasQLYzWgxK3CgI0d0C3Z5YcFkE5wm+yRVWyNJ pez1ouj/sAUjaTLO4Bdo6p8jkxpTNeJKz3BdnGBEmYZ0O7sIAayfNbYY/nrJNxUMVG oUA4W0+ANdrDn/MW0T+9CZbWU4EF9YQLyAvidAGjrorLoT1VMLXu3uMJorD/y7BJRe 2cBLFPlyR8V6adLnMtOYIsME2TkyS3yT85xYjiyFq/yTx1EGMEd9J7FzXuhZRWREyH JXL2mnojmHPVQ== 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>, Jean-Christophe Trotin <jean-christophe.trotin@foss.st.com> Subject: [PATCH v12 14/56] media: sti: hva: Use vb2_get_buffer() instead of directly access to buffers array Date: Tue, 17 Oct 2023 16:47:14 +0200 Message-Id: <20231017144756.34719-15-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017144756.34719-1-benjamin.gaignard@collabora.com> References: <20231017144756.34719-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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]); Tue, 17 Oct 2023 07:50:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780014680635969338 X-GMAIL-MSGID: 1780014680635969338 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Oct. 17, 2023, 2:47 p.m. UTC
Use vb2_get_buffer() instead of direct access to the vb2_queue bufs array.
This allows us to change the type of the bufs in the future.
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>
CC: Jean-Christophe Trotin <jean-christophe.trotin@foss.st.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; }