]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/tiny: sharp-memory: fix pointer error dereference
authorEthan Tidmore <ethantidmore06@gmail.com>
Mon, 16 Feb 2026 04:04:38 +0000 (22:04 -0600)
committerThomas Zimmermann <tzimmermann@suse.de>
Tue, 17 Feb 2026 09:04:28 +0000 (10:04 +0100)
The function devm_drm_dev_alloc() returns a pointer error upon failure
not NULL. Change null check to pointer error check.

Detected by Smatch:
drivers/gpu/drm/tiny/sharp-memory.c:549 sharp_memory_probe() error:
'smd' dereferencing possible ERR_PTR()

Fixes: b8f9f21716fec ("drm/tiny: Add driver for Sharp Memory LCD")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patch.msgid.link/20260216040438.43702-1-ethantidmore06@gmail.com
drivers/gpu/drm/tiny/sharp-memory.c

index 64272cd0f6e2261a309cb96f5848270a81d20be5..cbf69460ebf32df602f34c2b26d183bad3ce39cf 100644 (file)
@@ -541,8 +541,8 @@ static int sharp_memory_probe(struct spi_device *spi)
 
        smd = devm_drm_dev_alloc(dev, &sharp_memory_drm_driver,
                                 struct sharp_memory_device, drm);
-       if (!smd)
-               return -ENOMEM;
+       if (IS_ERR(smd))
+               return PTR_ERR(smd);
 
        spi_set_drvdata(spi, smd);