]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/st7571-i2c: Fix IS_ERR() vs NULL checks in probe()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 30 Apr 2025 08:03:46 +0000 (11:03 +0300)
committerJavier Martinez Canillas <javierm@redhat.com>
Wed, 30 Apr 2025 12:51:40 +0000 (14:51 +0200)
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>
Link: https://lore.kernel.org/r/aBHZYgPPPYY-J8Vd@stanley.mountain
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
drivers/gpu/drm/tiny/st7571-i2c.c

index dc410ec41baf3160a90af11907c921ea73867e97..eec846892962dce2d0b86c9c5c226d44135f2b0d 100644 (file)
@@ -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)