Skip to content

Commit b389df0

Browse files
Dan Carpentermartinezjavier
authored andcommitted
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: 4b35f0f ("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>
1 parent 0d607a5 commit b389df0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/gpu/drm/tiny/st7571-i2c.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -908,16 +908,14 @@ static int st7571_probe(struct i2c_client *client)
908908
st7571->hwbuf = devm_kzalloc(&client->dev,
909909
(st7571->nlines * st7571->ncols * st7571->bpp) / 8,
910910
GFP_KERNEL);
911-
if (IS_ERR(st7571->hwbuf))
912-
return dev_err_probe(&client->dev, PTR_ERR(st7571->hwbuf),
913-
"Failed to allocate intermediate buffer\n");
911+
if (!st7571->hwbuf)
912+
return -ENOMEM;
914913

915914
st7571->row = devm_kzalloc(&client->dev,
916915
(st7571->ncols * st7571->bpp),
917916
GFP_KERNEL);
918-
if (IS_ERR(st7571->row))
919-
return dev_err_probe(&client->dev, PTR_ERR(st7571->row),
920-
"Failed to allocate row buffer\n");
917+
if (!st7571->row)
918+
return -ENOMEM;
921919

922920
ret = st7571_mode_config_init(st7571);
923921
if (ret)

0 commit comments

Comments
 (0)