lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d7ed5f0c-0511-4833-86c1-3e1bae579ef3@amd.com>
Date: Tue, 15 Apr 2025 14:28:58 +0200
From: Christian König <christian.koenig@....com>
To: Philipp Stanner <phasta@...nel.org>, Lyude Paul <lyude@...hat.com>,
 Danilo Krummrich <dakr@...nel.org>, David Airlie <airlied@...il.com>,
 Simona Vetter <simona@...ll.ch>, Sabrina Dubroca <sd@...asysnail.net>,
 Sumit Semwal <sumit.semwal@...aro.org>
Cc: dri-devel@...ts.freedesktop.org, nouveau@...ts.freedesktop.org,
 linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
 linux-media@...r.kernel.org, linaro-mm-sig@...ts.linaro.org
Subject: Re: [PATCH v2 2/2] drm/nouveau: nouveau_fence: Standardize list
 iterations

Am 15.04.25 um 14:19 schrieb Philipp Stanner:
> nouveau_fence.c iterates over lists in a non-canonical way. Since the
> operations done are just basic for-each-loops, they should be written in
> the standard form.
>
> Use for_each_safe() instead of the custom loop iterations.
>
> Signed-off-by: Philipp Stanner <phasta@...nel.org>

Reviewed-by: Christian König <christian.koenig@....com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_fence.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
> index 6ded8c2b6d3b..60d961b43488 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
> @@ -84,11 +84,12 @@ void
>  nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error)
>  {
>  	struct nouveau_fence *fence;
> +	struct list_head *pos, *tmp;
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&fctx->lock, flags);
> -	while (!list_empty(&fctx->pending)) {
> -		fence = list_entry(fctx->pending.next, typeof(*fence), head);
> +	list_for_each_safe(pos, tmp, &fctx->pending) {
> +		fence = list_entry(pos, struct nouveau_fence, head);
>  
>  		if (error && !dma_fence_is_signaled_locked(&fence->base))
>  			dma_fence_set_error(&fence->base, error);
> @@ -131,11 +132,12 @@ static int
>  nouveau_fence_update(struct nouveau_channel *chan, struct nouveau_fence_chan *fctx)
>  {
>  	struct nouveau_fence *fence;
> +	struct list_head *pos, *tmp;
>  	int drop = 0;
>  	u32 seq = fctx->read(chan);
>  
> -	while (!list_empty(&fctx->pending)) {
> -		fence = list_entry(fctx->pending.next, typeof(*fence), head);
> +	list_for_each_safe(pos, tmp, &fctx->pending) {
> +		fence = list_entry(pos, struct nouveau_fence, head);
>  
>  		if ((int)(seq - fence->base.seqno) < 0)
>  			break;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ