[RESEND PATCH] drm/vmwgfx: Remove unnecessary NULL checks before kvfree()

Thorsten Blum posted 1 patch 1 month, 3 weeks ago
drivers/gpu/drm/vmwgfx/vmwgfx_blit.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[RESEND PATCH] drm/vmwgfx: Remove unnecessary NULL checks before kvfree()
Posted by Thorsten Blum 1 month, 3 weeks ago
Since kvfree() already checks if its argument is NULL, an additional
check before calling kvfree() is unnecessary and can be removed.

Remove both and the following Coccinelle/coccicheck warnings reported by
ifnullfree.cocci:

  WARNING: NULL check before some freeing functions is not needed
  WARNING: NULL check before some freeing functions is not needed

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_blit.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
index 890a66a2361f..64bd7d74854e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
@@ -635,10 +635,8 @@ int vmw_bo_cpu_blit(struct vmw_bo *vmw_dst,
 		kunmap_atomic(d.src_addr);
 	if (d.dst_addr)
 		kunmap_atomic(d.dst_addr);
-	if (src_pages)
-		kvfree(src_pages);
-	if (dst_pages)
-		kvfree(dst_pages);
+	kvfree(src_pages);
+	kvfree(dst_pages);
 
 	return ret;
 }
-- 
2.46.2
Re: [RESEND PATCH] drm/vmwgfx: Remove unnecessary NULL checks before kvfree()
Posted by Zack Rusin 1 month, 2 weeks ago
On Mon, Oct 7, 2024 at 7:52 AM Thorsten Blum <thorsten.blum@linux.dev> wrote:
>
> Since kvfree() already checks if its argument is NULL, an additional
> check before calling kvfree() is unnecessary and can be removed.
>
> Remove both and the following Coccinelle/coccicheck warnings reported by
> ifnullfree.cocci:
>
>   WARNING: NULL check before some freeing functions is not needed
>   WARNING: NULL check before some freeing functions is not needed
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_blit.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
> index 890a66a2361f..64bd7d74854e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c
> @@ -635,10 +635,8 @@ int vmw_bo_cpu_blit(struct vmw_bo *vmw_dst,
>                 kunmap_atomic(d.src_addr);
>         if (d.dst_addr)
>                 kunmap_atomic(d.dst_addr);
> -       if (src_pages)
> -               kvfree(src_pages);
> -       if (dst_pages)
> -               kvfree(dst_pages);
> +       kvfree(src_pages);
> +       kvfree(dst_pages);
>
>         return ret;
>  }
> --
> 2.46.2
>

Thank you. Looks good. I went ahead and pushed it to drm-misc-fixes.

z