[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94b9e0fd-2f4f-4d75-ae39-7d780a4e6374@moroto.mountain>
Date: Mon, 17 Jun 2024 15:02:56 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Detlev Casanova <detlev.casanova@...labora.com>
Cc: linux-kernel@...r.kernel.org,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Heiko Stuebner <heiko@...ech.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sebastian Reichel <sebastian.reichel@...labora.com>,
Dragan Simic <dsimic@...jaro.org>,
Alexey Charkov <alchark@...il.com>,
Cristian Ciocaltea <cristian.ciocaltea@...labora.com>,
Diederik de Haas <didi.debian@...ow.org>,
Andy Yan <andy.yan@...k-chips.com>, linux-media@...r.kernel.org,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-staging@...ts.linux.dev
Subject: Re: [PATCH 1/3] media: rockchip: Introduce the rkvdec2 driver
On Fri, Jun 14, 2024 at 09:56:27PM -0400, Detlev Casanova wrote:
> +static int rkvdec2_start_streaming(struct vb2_queue *q, unsigned int count)
> +{
> + struct rkvdec2_ctx *ctx = vb2_get_drv_priv(q);
> + const struct rkvdec2_coded_fmt_desc *desc;
> + int ret, i;
> + u32 width, height;
> +
> + if (V4L2_TYPE_IS_CAPTURE(q->type))
> + return 0;
> +
> + desc = ctx->coded_fmt_desc;
> + if (WARN_ON(!desc))
> + return -EINVAL;
> +
> + width = ctx->decoded_fmt.fmt.pix_mp.width;
> + height = ctx->decoded_fmt.fmt.pix_mp.height;
> + for (i = 0; i < RKVDEC2_RCB_COUNT; i++) {
> + ctx->rcb_bufs[i].cpu =
> + dma_alloc_coherent(ctx->dev->dev,
> + RCB_SIZE(i),
> + &ctx->rcb_bufs[i].dma,
> + GFP_KERNEL);
> + if (!ctx->rcb_bufs[i].cpu) {
> + ret = -ENOMEM;
> + goto err_rcb;
> + }
> + }
> +
> + if (desc->ops->start) {
> + ret = desc->ops->start(ctx);
> + if (ret)
> + goto err_ops_start;
> + }
> +
> + return 0;
> +
> +err_ops_start:
> +err_rcb:
> + i--;
> + while (i) {
> + dma_free_coherent(ctx->dev->dev,
> + RCB_SIZE(i),
> + ctx->rcb_bufs[i].cpu,
> + ctx->rcb_bufs[i].dma);
> + i--;
> + }
This will leak the first element of the ctx->rcb_bufs[i] array. The
traditional way to write this is either while (--i >= 0) or for unsigned
int i iterators it would be while (i--).
> +
> + return ret;
> +}
regards,
dan carpenter
Powered by blists - more mailing lists