[v15,11/56] media: mediatek: jpeg: Use vb2_get_buffer() instead of directly access to buffers array
Message ID | 20231109163008.179152-12-benjamin.gaignard@collabora.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp556225vqs; Thu, 9 Nov 2023 08:34:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwM2EVgxPb09LIXhTq576SlCmeSVkGPna4SMEypJOnkQQQdKBJR0F+jrpnAxe4yMNkX+Ln X-Received: by 2002:a17:902:e801:b0:1cc:2be7:c0f2 with SMTP id u1-20020a170902e80100b001cc2be7c0f2mr13198471plg.13.1699547658278; Thu, 09 Nov 2023 08:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699547658; cv=none; d=google.com; s=arc-20160816; b=rxRqVcHbCZe4R6G7dQxKFMKrmoUftRDp1YZsMMfCMGpqRsMCKCMh4K7htEeZ2xxIcU S4v9NJg/3jQFhAV2yGxrQgbddG+CznLhPWyErar7xkN5PPoyZr3DfW23ktdSs6wU/YkJ eqKVK5ylevckNtnONJEQ6VPwHxeJhCFwOHhXp6NcbhjG2V+ChJgwi1N9vVmv5/m2Xmhx kFL0Cy77wea2JshofSAXTI8zqws/v7mQLccS/PJ7HnA+1QLWEfg4kJU3Lx+VpfyAMVTZ sTbR+kStD/YgcMj7A/emsknkKpwxsjyiiyisjeJZSMHU6tpuNwzeoz/Tx0T+NTMqNvox QRmg== 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=uNW9skNjCNtNzBZC/0iZxAlLkA8q0EBUuoHGFFmZHiU=; fh=TmD+hhsp9BmE1gM0frR1Tlg23bmw2sQ+w3SEIAdpcT8=; b=jucvaKzvj4YiRtb8tuYi80Wk7wNW23gVVGg+otfeETemlQmNnrBSBND7faHLLTG6ie rwQk3xAgDZHDpHwd3D5jnoHqrAg+D0ZwCPeSqp2PZMNTgZwNhYXmthOrty4i82R+3Cn0 1U6Rbi7dhe1/EtEHRWRI75nvfDj/jg2FyPpcc79vzdBCZ/yTM4BOK5Axnfh+QT0e1V0X ZicK0UDQ9olYXBY0BTfOmE0d6aEG8irfzDCmEfvi8mscoPAECHDa1koTp0Lo1yANrCvU rSodroail+s+EPJmBq3nMR12TDD9JEuu9CLteilbLgBcyF9mgDSiQUEbQKJBH0mC7vi6 GYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YRTFfYth; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id t3-20020a170902d14300b001c76a2ebda0si4661664plt.502.2023.11.09.08.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 08:34:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YRTFfYth; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id A1E9380F66A0; Thu, 9 Nov 2023 08:34:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234850AbjKIQdV (ORCPT <rfc822;lhua1029@gmail.com> + 31 others); Thu, 9 Nov 2023 11:33:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234849AbjKIQc4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Nov 2023 11:32:56 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C1F73AA3; Thu, 9 Nov 2023 08:32:49 -0800 (PST) Received: from benjamin-XPS-13-9310.. (cola.collaboradmins.com [195.201.22.229]) (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 B95D6660741B; Thu, 9 Nov 2023 16:32:47 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1699547568; bh=Rc139ZSiENtAf3eeg15Uf2jQ+z0mqRTeA477enaPk00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YRTFfYthaY4HhtKOvytssmx3dCb/i9cbFo7DgAW/9XPZmRt3PeKIrN9P6bOPqbeqX DVMYNjwBRSM9xQu69BWhZE1EytExoFmmIxwHameLFEvNmp2qTFGv4cojaVdQqPOwWx AF+QMDV9Xg9OpzhvPNf/Pi0bXRwbzFTPWuWfu+qgLh/gnHs1GOBBIs2pxOZOK+3tE7 PnpbsTglsglAngmm40my1cIG7x3lp4xZzbv/DQYCoz9Hji6uXKTICtFAv2T8tgO/IH YBrIF0tAlqtOgXhIvQ1og5/iJ1I5sHx/qUX6UoqpJtG02GWNamvjylntwzWgmGieEJ 1FICylyP/3M3w== 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>, Andrzej Pietrasiewicz <andrzej.p@collabora.com>, Bin Liu <bin.liu@mediatek.com>, Matthias Brugger <matthias.bgg@gmail.com> Subject: [PATCH v15 11/56] media: mediatek: jpeg: Use vb2_get_buffer() instead of directly access to buffers array Date: Thu, 9 Nov 2023 17:29:23 +0100 Message-Id: <20231109163008.179152-12-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109163008.179152-1-benjamin.gaignard@collabora.com> References: <20231109163008.179152-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (agentk.vger.email [0.0.0.0]); Thu, 09 Nov 2023 08:34:03 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782104885769583483 X-GMAIL-MSGID: 1782104885769583483 |
Series |
Add DELETE_BUF ioctl
|
|
Commit Message
Benjamin Gaignard
Nov. 9, 2023, 4:29 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> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> CC: Bin Liu <bin.liu@mediatek.com> CC: Matthias Brugger <matthias.bgg@gmail.com> --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 7194f88edc0f..73a063b1569b 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -598,12 +598,11 @@ static int mtk_jpeg_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) goto end; vq = v4l2_m2m_get_vq(fh->m2m_ctx, buf->type); - if (buf->index >= vq->num_buffers) { - dev_err(ctx->jpeg->dev, "buffer index out of range\n"); + vb = vb2_get_buffer(vq, buf->index); + if (!vb) { + dev_err(ctx->jpeg->dev, "buffer not found\n"); return -EINVAL; } - - vb = vq->bufs[buf->index]; jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(vb); jpeg_src_buf->bs_size = buf->m.planes[0].bytesused;