diff mbox series

[5.10] drm/mediatek: Fix backport issue in mtk_drm_gem_prime_vmap()

Message ID 20230922-5-10-fix-drm-mediatek-backport-v1-1-912d76cd4a96@kernel.org (mailing list archive)
State New, archived
Headers show
Series [5.10] drm/mediatek: Fix backport issue in mtk_drm_gem_prime_vmap() | expand

Commit Message

Nathan Chancellor Sept. 22, 2023, 3:51 p.m. UTC
When building with clang:

  drivers/gpu/drm/mediatek/mtk_drm_gem.c:255:10: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'void *' [-Wint-conversion]
    255 |                 return -ENOMEM;
        |                        ^~~~~~~
  1 error generated.

GCC reports the same issue as a warning, rather than an error.

Prior to commit 7e542ff8b463 ("drm/mediatek: Use struct dma_buf_map in
GEM vmap ops"), this function returned a pointer rather than an integer.
This function is indirectly called in drm_gem_vmap(), which treats NULL
as -ENOMEM through an error pointer. Return NULL in this block to
resolve the warning but keep the same end result.

Fixes: 43f561e809aa ("drm/mediatek: Fix potential memory leak if vmap() fail")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
This is a fix for a 5.10 backport, so it has no upstream relevance but
I've still cc'd the relevant maintainers in case they have any comments
or want to double check my work.
---
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: ff0bfa8f23eb4c5a65ee6b0d0b7dc2e3439f1063
change-id: 20230922-5-10-fix-drm-mediatek-backport-0ee69329fef0

Best regards,

Comments

Nick Desaulniers Sept. 29, 2023, 4:11 p.m. UTC | #1
On Fri, Sep 22, 2023 at 8:51 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When building with clang:
>
>   drivers/gpu/drm/mediatek/mtk_drm_gem.c:255:10: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'void *' [-Wint-conversion]
>     255 |                 return -ENOMEM;
>         |                        ^~~~~~~
>   1 error generated.
>
> GCC reports the same issue as a warning, rather than an error.
>
> Prior to commit 7e542ff8b463 ("drm/mediatek: Use struct dma_buf_map in
> GEM vmap ops"), this function returned a pointer rather than an integer.
> This function is indirectly called in drm_gem_vmap(), which treats NULL
> as -ENOMEM through an error pointer. Return NULL in this block to
> resolve the warning but keep the same end result.
>
> Fixes: 43f561e809aa ("drm/mediatek: Fix potential memory leak if vmap() fail")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

(resending as text/plain)
Did this get picked up? Our CI has been red for a few days on
linux-5.10.y over this.

> ---
> This is a fix for a 5.10 backport, so it has no upstream relevance but
> I've still cc'd the relevant maintainers in case they have any comments
> or want to double check my work.
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> index fe64bf2176f3..b20ea58907c2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> @@ -252,7 +252,7 @@ void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj)
>         if (!mtk_gem->kvaddr) {
>                 kfree(sgt);
>                 kfree(mtk_gem->pages);
> -               return -ENOMEM;
> +               return NULL;
>         }
>  out:
>         kfree(sgt);
>
> ---
> base-commit: ff0bfa8f23eb4c5a65ee6b0d0b7dc2e3439f1063
> change-id: 20230922-5-10-fix-drm-mediatek-backport-0ee69329fef0
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
>
Greg KH Oct. 7, 2023, 9:56 a.m. UTC | #2
On Fri, Sep 22, 2023 at 08:51:17AM -0700, Nathan Chancellor wrote:
> When building with clang:
> 
>   drivers/gpu/drm/mediatek/mtk_drm_gem.c:255:10: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'void *' [-Wint-conversion]
>     255 |                 return -ENOMEM;
>         |                        ^~~~~~~
>   1 error generated.
> 
> GCC reports the same issue as a warning, rather than an error.
> 
> Prior to commit 7e542ff8b463 ("drm/mediatek: Use struct dma_buf_map in
> GEM vmap ops"), this function returned a pointer rather than an integer.
> This function is indirectly called in drm_gem_vmap(), which treats NULL
> as -ENOMEM through an error pointer. Return NULL in this block to
> resolve the warning but keep the same end result.
> 
> Fixes: 43f561e809aa ("drm/mediatek: Fix potential memory leak if vmap() fail")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> This is a fix for a 5.10 backport, so it has no upstream relevance but
> I've still cc'd the relevant maintainers in case they have any comments
> or want to double check my work.

Now queued up, thanks.

greg k-h
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
index fe64bf2176f3..b20ea58907c2 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
@@ -252,7 +252,7 @@  void *mtk_drm_gem_prime_vmap(struct drm_gem_object *obj)
 	if (!mtk_gem->kvaddr) {
 		kfree(sgt);
 		kfree(mtk_gem->pages);
-		return -ENOMEM;
+		return NULL;
 	}
 out:
 	kfree(sgt);