The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drm/tiny: sharp-memory: fix pointer error dereference
@ 2026-02-16  4:04 Ethan Tidmore
  2026-02-16  6:10 ` Uwe Kleine-König
  2026-02-17  8:41 ` Thomas Zimmermann
  0 siblings, 2 replies; 3+ messages in thread
From: Ethan Tidmore @ 2026-02-16  4:04 UTC (permalink / raw)
  To: lanzano.alex
  Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona, lumag,
	mehdi.djait, u.kleine-koenig, dri-devel, linux-kernel,
	Ethan Tidmore

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>
---
 drivers/gpu/drm/tiny/sharp-memory.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sharp-memory.c
index 64272cd0f6e2..cbf69460ebf3 100644
--- a/drivers/gpu/drm/tiny/sharp-memory.c
+++ b/drivers/gpu/drm/tiny/sharp-memory.c
@@ -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);
 
-- 
2.53.0


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

* Re: [PATCH] drm/tiny: sharp-memory: fix pointer error dereference
  2026-02-16  4:04 [PATCH] drm/tiny: sharp-memory: fix pointer error dereference Ethan Tidmore
@ 2026-02-16  6:10 ` Uwe Kleine-König
  2026-02-17  8:41 ` Thomas Zimmermann
  1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2026-02-16  6:10 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: lanzano.alex, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona, lumag, mehdi.djait, dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 548 bytes --]

On Sun, Feb 15, 2026 at 10:04:38PM -0600, Ethan Tidmore wrote:
> 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>

Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] drm/tiny: sharp-memory: fix pointer error dereference
  2026-02-16  4:04 [PATCH] drm/tiny: sharp-memory: fix pointer error dereference Ethan Tidmore
  2026-02-16  6:10 ` Uwe Kleine-König
@ 2026-02-17  8:41 ` Thomas Zimmermann
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2026-02-17  8:41 UTC (permalink / raw)
  To: Ethan Tidmore, lanzano.alex
  Cc: maarten.lankhorst, mripard, airlied, simona, lumag, mehdi.djait,
	u.kleine-koenig, dri-devel, linux-kernel



Am 16.02.26 um 05:04 schrieb Ethan Tidmore:
> 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>

Thanks for the fix.

> ---
>   drivers/gpu/drm/tiny/sharp-memory.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sharp-memory.c
> index 64272cd0f6e2..cbf69460ebf3 100644
> --- a/drivers/gpu/drm/tiny/sharp-memory.c
> +++ b/drivers/gpu/drm/tiny/sharp-memory.c
> @@ -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);
>   

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)



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

end of thread, other threads:[~2026-02-17  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-16  4:04 [PATCH] drm/tiny: sharp-memory: fix pointer error dereference Ethan Tidmore
2026-02-16  6:10 ` Uwe Kleine-König
2026-02-17  8:41 ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox