From nobody Thu Nov 14 05:13:41 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F12A7E784BE for ; Mon, 2 Oct 2023 12:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237056AbjJBMGz (ORCPT ); Mon, 2 Oct 2023 08:06:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236957AbjJBMGb (ORCPT ); Mon, 2 Oct 2023 08:06:31 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB5FD8; Mon, 2 Oct 2023 05:06:28 -0700 (PDT) Received: from benjamin-XPS-13-9310.. (unknown [IPv6:2a01:e0a:120:3210:9537:67ca:c85e:d0ae]) (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 8E75666072FB; Mon, 2 Oct 2023 13:06:26 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696248387; bh=swS7yYiqBxggjIra2XX2pXDY4PPq3f683TK0rKa6DhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=giuIe/fVSLygz4HErc6sFwbwJmDnvrm52UiCkx/M2fccRfO+Ne0i+/neDDX39GxNa KfVc3COaAoRLhuBm+BIKJ4NznCR0J0M4IFn247wArNNfQMouLhriiuR4CwYdsVJEmy T6sGr47TfKy/1+xLr38gwF7rvzU0NtGYvT5olCNNaO6QyoKEqXUziy/QI19UEriG0L ELooCGI0b7wmeddY7d5sPc4c6SQ6RFr/Nw4WKaiHriBeRJCEw2msFICeRCaKNCELEK mzK/yFia3472lzjIY7nkpfqvsSPFHVrKUFveTRI+Jj4WeNutHFdMvM/WOA0HItc3Zp t/wxBw5fWS8kQ== From: Benjamin Gaignard 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 Subject: [PATCH v9 04/53] media: amphion: Use vb2_get_buffer() instead of directly access to buffers array Date: Mon, 2 Oct 2023 14:05:28 +0200 Message-Id: <20231002120617.119602-5-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231002120617.119602-1-benjamin.gaignard@collabora.com> References: <20231002120617.119602-1-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- drivers/media/platform/amphion/vpu_dbg.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/amphion/vpu_dbg.c b/drivers/media/platf= orm/amphion/vpu_dbg.c index 982c2c777484..a462d6fe4ea9 100644 --- a/drivers/media/platform/amphion/vpu_dbg.c +++ b/drivers/media/platform/amphion/vpu_dbg.c @@ -140,11 +140,18 @@ static int vpu_dbg_instance(struct seq_file *s, void = *data) =20 vq =3D v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); for (i =3D 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb =3D vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb =3D vb2_get_buffer(vq, i); + if (!vb) + continue; =20 if (vb->state =3D=3D VB2_BUF_STATE_DEQUEUED) continue; + + vbuf =3D to_vb2_v4l2_buffer(vb); + num =3D scnprintf(str, sizeof(str), "output [%2d] state =3D %10s, %8s\n", i, vb2_stat_name[vb->state], @@ -155,11 +162,18 @@ static int vpu_dbg_instance(struct seq_file *s, void = *data) =20 vq =3D v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); for (i =3D 0; i < vq->num_buffers; i++) { - struct vb2_buffer *vb =3D vq->bufs[i]; - struct vb2_v4l2_buffer *vbuf =3D to_vb2_v4l2_buffer(vb); + struct vb2_buffer *vb; + struct vb2_v4l2_buffer *vbuf; + + vb =3D vb2_get_buffer(vq, i); + if (!vb) + continue; =20 if (vb->state =3D=3D VB2_BUF_STATE_DEQUEUED) continue; + + vbuf =3D to_vb2_v4l2_buffer(vb); + num =3D scnprintf(str, sizeof(str), "capture[%2d] state =3D %10s, %8s\n", i, vb2_stat_name[vb->state], --=20 2.39.2