* [PATCH] drm/tiny: sharp-memory: reject devices without match data
@ 2026-09-25 12:36 Jiale Yao
2026-09-26 6:32 ` Uwe Kleine-König
0 siblings, 1 reply; 2+ messages in thread
From: Jiale Yao @ 2026-09-25 12:36 UTC (permalink / raw)
To: Alex Lanzano, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov,
Uwe Kleine-König, Mehdi Djait, dri-devel, linux-kernel
Cc: Jiale Yao, stable
SPI driver_override allows a device to bind to this driver without
matching either the OF or SPI device ID table. In that case,
spi_get_device_match_data() returns NULL.
sharp_memory_probe() immediately dereferences the returned display mode
to calculate the pitch and transmit buffer size, causing a NULL pointer
dereference.
Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match
data") fixed the same driver_override issue in another SPI driver.
Reject devices without match data before using the display mode.
Fixes: b8f9f21716fe ("drm/tiny: Add driver for Sharp Memory LCD")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/gpu/drm/tiny/sharp-memory.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sharp-memory.c
index 7efd7b567f3b..049e98f657f3 100644
--- a/drivers/gpu/drm/tiny/sharp-memory.c
+++ b/drivers/gpu/drm/tiny/sharp-memory.c
@@ -557,6 +557,8 @@ static int sharp_memory_probe(struct spi_device *spi)
drm->mode_config.funcs = &sharp_memory_mode_config_funcs;
smd->mode = spi_get_device_match_data(spi);
+ if (!smd->mode)
+ return -ENODATA;
smd->pitch = (SHARP_ADDR_PERIOD + smd->mode->hdisplay + SHARP_DUMMY_PERIOD) / 8;
smd->tx_buffer_size = (SHARP_MODE_PERIOD +
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/tiny: sharp-memory: reject devices without match data
2026-09-25 12:36 [PATCH] drm/tiny: sharp-memory: reject devices without match data Jiale Yao
@ 2026-09-26 6:32 ` Uwe Kleine-König
0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2026-09-26 6:32 UTC (permalink / raw)
To: Jiale Yao
Cc: Alex Lanzano, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov,
Mehdi Djait, dri-devel, linux-kernel, stable
[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]
Hello,
On Fri, Sep 25, 2026 at 08:36:08PM +0800, Jiale Yao wrote:
> SPI driver_override allows a device to bind to this driver without
> matching either the OF or SPI device ID table. In that case,
> spi_get_device_match_data() returns NULL.
>
> sharp_memory_probe() immediately dereferences the returned display mode
> to calculate the pitch and transmit buffer size, causing a NULL pointer
> dereference.
>
> Commit 572a00852635 ("iio: dac: ad5686: missing NULL check on match
> data") fixed the same driver_override issue in another SPI driver.
> Reject devices without match data before using the display mode.
>
> Fixes: b8f9f21716fe ("drm/tiny: Add driver for Sharp Memory LCD")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiale Yao <yaojiale02@163.com>
Note there is an effort to make it impossible to use driver_override in
the core and only allow a few dedicated drivers. (See
https://lore.kernel.org/lkml/20260922-driver-override-opt-out-v1-0-58c35ded3b83@nvidia.com/)
That should make your effort to implement that check in all the driver
redundant.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-26 6:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 12:36 [PATCH] drm/tiny: sharp-memory: reject devices without match data Jiale Yao
2026-09-26 6:32 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®