diff mbox series

drm: use ENOMEM for drmm_kzalloc allocation failures

Message ID 20220521234104.88410-1-dossche.niels@gmail.com (mailing list archive)
State New, archived
Headers show
Series drm: use ENOMEM for drmm_kzalloc allocation failures | expand

Commit Message

Niels Dossche May 21, 2022, 11:41 p.m. UTC
Other callers of drmm_kzalloc already return -ENOMEM on allocation
failure. Change EINVAL to ENOMEM for consistency.

Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---

Note:
I found this issue using my experimental static analyser on Linux
5.17.9. I compile tested the patch on x86_64.

 drivers/gpu/drm/drm_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Vetter May 25, 2022, 3:39 p.m. UTC | #1
On Sun, May 22, 2022 at 01:41:04AM +0200, Niels Dossche wrote:
> Other callers of drmm_kzalloc already return -ENOMEM on allocation
> failure. Change EINVAL to ENOMEM for consistency.
> 
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>

Thanks, applied to drm-misc-next.
-Daniel

> ---
> 
> Note:
> I found this issue using my experimental static analyser on Linux
> 5.17.9. I compile tested the patch on x86_64.
> 
>  drivers/gpu/drm/drm_encoder.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
> index 72e982323a5e..a940024c8087 100644
> --- a/drivers/gpu/drm/drm_encoder.c
> +++ b/drivers/gpu/drm/drm_encoder.c
> @@ -226,7 +226,7 @@ void *__drmm_encoder_alloc(struct drm_device *dev, size_t size, size_t offset,
>  
>  	container = drmm_kzalloc(dev, size, GFP_KERNEL);
>  	if (!container)
> -		return ERR_PTR(-EINVAL);
> +		return ERR_PTR(-ENOMEM);
>  
>  	encoder = container + offset;
>  
> -- 
> 2.36.0
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index 72e982323a5e..a940024c8087 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -226,7 +226,7 @@  void *__drmm_encoder_alloc(struct drm_device *dev, size_t size, size_t offset,
 
 	container = drmm_kzalloc(dev, size, GFP_KERNEL);
 	if (!container)
-		return ERR_PTR(-EINVAL);
+		return ERR_PTR(-ENOMEM);
 
 	encoder = container + offset;