Skip to contentSkip to conversation

drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe()

PATCH Applied Dan Carpenter 2 participants 3 messages Apr 30, 2025

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

PATCH 1/1 drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe()

The devm_kzalloc() function returns NULL on failure, not error pointers. Also printing an error message for kmalloc() failures is against kernel style so just return -ENOMEM without printing a message. (Kmalloc already prints a message).

Fixes 4b35f0f41ee2 ("drm/st7571-i2c: add support for Sitronix ST7571 LCD controller")
---
 drivers/gpu/drm/tiny/st7571-i2c.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/tiny/st7571-i2c.c +4 -6
index dc410ec41baf..eec846892962 100644
@@ -908,16 +908,14 @@ static int st7571_probe(struct i2c_client *client)
 	st7571->hwbuf = devm_kzalloc(&client->dev,
 				     (st7571->nlines * st7571->ncols * st7571->bpp) / 8,
 				     GFP_KERNEL);
-	if (IS_ERR(st7571->hwbuf))
-		return dev_err_probe(&client->dev, PTR_ERR(st7571->hwbuf),
-				     "Failed to allocate intermediate buffer\n");
+	if (!st7571->hwbuf)
+		return -ENOMEM;
 
 	st7571->row = devm_kzalloc(&client->dev,
 				   (st7571->ncols * st7571->bpp),
 				   GFP_KERNEL);
-	if (IS_ERR(st7571->row))
-		return dev_err_probe(&client->dev, PTR_ERR(st7571->row),
-				     "Failed to allocate row buffer\n");
+	if (!st7571->row)
+		return -ENOMEM;
 
 	ret = st7571_mode_config_init(st7571);
 	if (ret)
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw

Dan Carpenter <[email protected]> writes:

Hello Dan,

Quoted 8 lines

The devm_kzalloc() function returns NULL on failure, not error pointers. Also printing an error message for kmalloc() failures is against kernel style so just return -ENOMEM without printing a message. (Kmalloc already prints a message).

Fixes 4b35f0f41ee2 ("drm/st7571-i2c: add support for Sitronix ST7571 LCD controller")

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#2 lore raw
Quoted 9 lines · Javier Martinez Canillas

Dan Carpenter <[email protected]> writes:

Hello Dan,

Quoted 5 lines

The devm_kzalloc() function returns NULL on failure, not error pointers. Also printing an error message for kmalloc() failures is against kernel style so just return -ENOMEM without printing a message. (Kmalloc already prints a message).

Quoted 6 lines
Quoted 3 lines
Fixes 4b35f0f41ee2 ("drm/st7571-i2c: add support for Sitronix ST7571 LCD controller")

---

Pushed to drm-misc (drm-misc-next). Thanks!

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat