All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe()
@ 2025-04-30  8:03 Dan Carpenter
  2025-04-30 12:47 ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-04-30  8:03 UTC (permalink / raw)
  To: Marcus Folkesson
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Javier Martinez Canillas, dri-devel, linux-kernel,
	kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/tiny/st7571-i2c.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tiny/st7571-i2c.c b/drivers/gpu/drm/tiny/st7571-i2c.c
index dc410ec41baf..eec846892962 100644
--- a/drivers/gpu/drm/tiny/st7571-i2c.c
+++ b/drivers/gpu/drm/tiny/st7571-i2c.c
@@ -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)
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH next] drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe()
  2025-04-30  8:03 [PATCH next] drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe() Dan Carpenter
@ 2025-04-30 12:47 ` Javier Martinez Canillas
  2025-04-30 13:00   ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2025-04-30 12:47 UTC (permalink / raw)
  To: Dan Carpenter, Marcus Folkesson
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, dri-devel, linux-kernel, kernel-janitors

Dan Carpenter <dan.carpenter@linaro.org> writes:

Hello Dan,

> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH next] drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe()
  2025-04-30 12:47 ` Javier Martinez Canillas
@ 2025-04-30 13:00   ` Javier Martinez Canillas
  0 siblings, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2025-04-30 13:00 UTC (permalink / raw)
  To: Dan Carpenter, Marcus Folkesson
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, dri-devel, linux-kernel, kernel-janitors

Javier Martinez Canillas <javierm@redhat.com> writes:

> Dan Carpenter <dan.carpenter@linaro.org> writes:
>
> Hello Dan,
>
>> 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")
>> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>> ---
>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>

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

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-30 13:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30  8:03 [PATCH next] drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe() Dan Carpenter
2025-04-30 12:47 ` Javier Martinez Canillas
2025-04-30 13:00   ` Javier Martinez Canillas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.