[v13,18/56] media: dvb-core: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231019125222.21370-19-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:2010:b0:403:3b70:6f57 with SMTP id fe16csp360337vqb; Thu, 19 Oct 2023 05:56:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE9PxG+f7SWw6OpEO1AkYA2L/zKNsup78+vQQYW2Ef8fe4Ps0yv4lLXXjAmQ1VIK+dGO3r3 X-Received: by 2002:a05:6a20:a0a5:b0:15e:1486:1e08 with SMTP id r37-20020a056a20a0a500b0015e14861e08mr1517241pzj.19.1697720171720; Thu, 19 Oct 2023 05:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697720171; cv=none; d=google.com; s=arc-20160816; b=OAwP16ivuJBUpEx3rEzTTrR5jhKqmDygkIzqz4os3ojmaeNzJLCgBMCSbCUOcXlZEo eLsGXY4H0k1pBoQNInGKocghb2toPOFPgBKSpw+xjSPEWeT42HAb73wgq+bUNpvMV6ya VrXL0bqc43Ag6csrPOsErUuUJhyDDGwFQPUl8qLL/W8i2i/G7CnwD11klyPR9ByMcKLI 6CiU6SDNkjqlTlZKUXyOk5lt09epBlO6hC9/SzfJu0EGZabAW732/2t0c/gQbnxUtKYD NMOrkrdy6mVpH+yXGB2aU50Cupj8lVB8t4E+yJlDyRy61oW9OmKApBGn6Td7q1QiSzSL qwyQ== 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=rssmHwRaLIgaYrDGGoiR2bvUGHmWTIHsQMhsS5T9D0o=; fh=ceA81l8d2hZW6pWH7VE5TwJxtgXUzAubfWIMcikPA1M=; b=Dq6MSYHjqbuFTof9MlPKAf9mHdnWfPsGlSG+Ko2JXHboZvg7/1Ds/CV31zTv0wZ2ys A6K3+kXYZFkAMwFTrWNyRhNjt8wmpFrJon6uCb0I2OBu4+fEj6/cI8I3Jun6u9epr1JH TwSbTOcmghjW0rYAaNQmpe7ab0aUD7Y2XVN6chKE7cHtQGT+ZZN6DvayVXW81dSdRQsC 5LkPWXTqEj7Ep+LH7eV3VIVEvrFq4nNDgk9/qntOU7yQdb/p/DPpteLBeMlNtGsE7ncG 4128PlytoU3XGa3DKRgXyZRFCYt/Vwm5ZksJWVsDFPYZqhb0z4MmGd768HUU7tgktU5g Ho9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nL0yETWi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 195-20020a6301cc000000b005aa7f52fe5esi4454734pgb.111.2023.10.19.05.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:56:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nL0yETWi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 35CE3805CDAF; Thu, 19 Oct 2023 05:55:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345997AbjJSMxs (ORCPT <rfc822;lkml4gm@gmail.com> + 25 others); Thu, 19 Oct 2023 08:53:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345793AbjJSMwq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 19 Oct 2023 08:52:46 -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 72F64187; Thu, 19 Oct 2023 05:52:41 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:ccea:1fb5:34eb:239b]) (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 E6545660735F; Thu, 19 Oct 2023 13:52:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1697719960; bh=/R1pnW8jfIuOE9V1pOiXWbvwVFtKNqZCCdQZpnNVq6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nL0yETWiO024SU0YGHLbfamIJY5I86dPn+T+jJUM99H43AtnlxZRD+FomJWd5Hudl qzFnbA+PEk0/R4+u4AuesvF2r/waIBsr6a/zt0+Hn2KXbm/EDiby+N0CYrPnRcoiJj gHAwE2e9vlUKvVjLox/3TAfDirnXL7SvTGJx8QbtqNWCAeOflyI7PrLW1hxjGxFjMZ QzfilOTAAwEegLD0LysuJaalKwJoipQ6Skdvu8FZMat7OGxKaksT9qvQfeUbLOg0zh O8EnlA3a7vy12/janVh/lRwFxyUoU0QmMwFPcBuLp8qEXdrqE3PxftJwwnPquJqhJB XOm4MLE0dodDg== 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 v13 18/56] media: dvb-core: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 19 Oct 2023 14:51:44 +0200 Message-Id: <20231019125222.21370-19-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019125222.21370-1-benjamin.gaignard@collabora.com> References: <20231019125222.21370-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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:55:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780188626788371265 X-GMAIL-MSGID: 1780188626788371265 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Oct. 19, 2023, 12:51 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.
Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
---
drivers/media/dvb-core/dvb_vb2.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
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);