Message ID | 20231012114642.19040-19-benjamin.gaignard@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 483F1CDB47E for <linux-arm-kernel@archiver.kernel.org>; Thu, 12 Oct 2023 11:49:40 +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=XOQKRACJR7LQPhVjtc+AlUFPQG1mOzQxLS8/Alc9eMw=; b=jLz+KLE8cFCTYi tgNh81TApyDX+QXMNET4AMyXl8eSWYV7vQm5cjEgLqKp35rTmK3zDrtPG41Fg8r+3hDf8lHIgUob7 4ARLPGqWmvadxXPvGaEz5V4ThuKzOEy/92zAIbKKIPJbVMZVJbnc+rOOPZ7nrwXFHChoCuRqtUpSx zSTZvwTmDqYo8+owDdk+1BZxKYOpcOy5p1RUvOO4h4w+ssgN6LtM9bPxzNq3+MB2NmxF5Vsiy9227 1poTzmgjFynry56NINgFC0HsilNJ4vLbpIVSuCCG2zMTl8rokXJNaHH95AzwhXWR/YJ819O3p2/xh B3FB9BTjsS1IUVt56GsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qquBn-000pzx-1H; Thu, 12 Oct 2023 11:49:15 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqu9m-000oBq-2a; Thu, 12 Oct 2023 11:47:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=aDL5gETzUiP0VzZZCijO3U9Zzi9a1aLBhnH2wBWpEGU=; b=mFarfUsMlzY5J7aNzSp1xO27A5 2LJErNB/rCQin2+PEuPhoUMSyUqOe35OAN6iudrybQz1jzKJjsMOnxrKIZBy9SdzXXgXSwvhvxFjd ageQKFqWWuykg3LIn14Xquj3BRkFnw+aiGL/BR4t6ruwmSNzLkjW6FgsnXdMawzyC9w+2qlycpO1+ 5Urvg2lj89ZB5X/niX+9MMwL2g0/dohGgKlN59/Mv//G8ZgqhCnXcDsXRqNMvcxj9sWjoxiY+MXcN 1FfmHJzy6THnGf4HnFGP8PH/9sdzBmVudm+HYAxxWwee5fvwp8j3rnVtLRBxmke46TwYJJC1kOqeX nU3UR0JQ==; Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqu9c-001nHr-1r; Thu, 12 Oct 2023 11:47:08 +0000 Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:7ae7:b86d:c19a:877e]) (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 EA8AD660736B; Thu, 12 Oct 2023 12:46:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697111219; bh=EMKVWITArl2PHuWHDFd/NcTii9pr6T7GjKNa1Tuop1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=khy5hIdLyuzHv4KJZZ2yr72/PXDrFjCI6XCW/IgkECTXGG0O0HSooxknKod+2r8vE c6kcJqjIApQNzeXmpVPcx6sqb1BOJCtv/x22TCE3STSG18W0/KU40PS1qNo7VwYtfo xv6J1UVmI6eGMO5Ggzh1dUNVQTQWYNhjcBUT0S2gBBBzqPkYGtvT8xT3mFgJ1WB/lq 3sYZzTDGiyPPdniFyIyOGBN3ESSxS0u8YxPaFgmWcPlBXz0PRdOh3xifIZ0uth+eKu r6fZ8vPfNl7/1tSfGK284dxAquGEnIA2/yA7EAtz9v6wBxH3LFmYunWhRedKR3fBw5 Yyf+rN1DuRz8Q== 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 v11 18/56] media: dvb-core: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 12 Oct 2023 13:46:04 +0200 Message-Id: <20231012114642.19040-19-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231012114642.19040-1-benjamin.gaignard@collabora.com> References: <20231012114642.19040-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231012_124702_244894_60042835 X-CRM114-Status: GOOD ( 11.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Add DELETE_BUF ioctl
|
expand
|
diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c index b322ef179f05..3a966fdf814c 100644 --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -355,12 +355,13 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req) int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { struct vb2_queue *q = &ctx->vb_q; + struct vb2_buffer *vb2 = vb2_get_buffer(q, b->index); - if (b->index >= q->num_buffers) { - dprintk(1, "[%s] buffer index out of range\n", ctx->name); + if (!vb2) { + dprintk(1, "[%s] invalid buffer index\n", ctx->name); return -EINVAL; } - vb2_core_querybuf(&ctx->vb_q, q->bufs[b->index], b); + vb2_core_querybuf(&ctx->vb_q, vb2, b); dprintk(3, "[%s] index=%d\n", ctx->name, b->index); return 0; } @@ -385,13 +386,14 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp) int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b) { struct vb2_queue *q = &ctx->vb_q; + struct vb2_buffer *vb2 = vb2_get_buffer(q, b->index); int ret; - if (b->index >= q->num_buffers) { - dprintk(1, "[%s] buffer index out of range\n", ctx->name); + if (!vb2) { + dprintk(1, "[%s] invalid buffer index\n", ctx->name); return -EINVAL; } - ret = vb2_core_qbuf(&ctx->vb_q, q->bufs[b->index], b, NULL); + ret = vb2_core_qbuf(&ctx->vb_q, vb2, b, NULL); if (ret) { dprintk(1, "[%s] index=%d errno=%d\n", ctx->name, b->index, ret);
Use vb2_get_buffer() instead of directly access to vb2_buffer buffer array. This could allow to change the type bufs[] field of vb2_buffer structure if needed. 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. Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> --- drivers/media/dvb-core/dvb_vb2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)