Skip to contentSkip to conversation

drm: use ENOMEM for drmm_kzalloc allocation failures

PATCH Applied Niels Dossche 2 participants 2 messages May 23, 2022 – May 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: use ENOMEM for drmm_kzalloc allocation failures

Other callers of drmm_kzalloc already return -ENOMEM on allocation failure. Change EINVAL to ENOMEM for consistency.

---

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(-)
drivers/gpu/drm/drm_encoder.c +1 -1
index 72e982323a5e..a940024c8087 100644
@@ -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;
 
Signature · 1 line
2.36.0
#1 lore raw
Quoted 4 lines · Niels Dossche

Other callers of drmm_kzalloc already return -ENOMEM on allocation failure. Change EINVAL to ENOMEM for consistency.

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

Quoted 25 lines

---

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(-)
drivers/gpu/drm/drm_encoder.c +1 -1
index 72e982323a5e..a940024c8087 100644
@@ -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;
 
Signature · 1 line
2.36.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch