[PATCH] Input: goodix_berlin - reject devices without match data

From: Jiale Yao

Date: Fri Sep 25 2026 - 09:42:56 EST


A device bound through driver_override need not match an entry in the
driver tables. In that case spi_get_device_match_data() returns NULL,
but goodix_berlin_spi_probe() dereferences the result while calculating
the regmap transfer limits.

Reject devices without match data before using the chip information.

Fixes: 4d395cb071a3 ("Input: goodix_berlin - add support for Berlin-A series")
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/input/touchscreen/goodix_berlin_spi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/goodix_berlin_spi.c b/drivers/input/touchscreen/goodix_berlin_spi.c
index 01f850f484c2..db9e151ced65 100644
--- a/drivers/input/touchscreen/goodix_berlin_spi.c
+++ b/drivers/input/touchscreen/goodix_berlin_spi.c
@@ -127,12 +127,16 @@ static const struct input_id goodix_berlin_spi_input_id = {

static int goodix_berlin_spi_probe(struct spi_device *spi)
{
- const struct goodix_berlin_ic_data *ic_data = spi_get_device_match_data(spi);
+ const struct goodix_berlin_ic_data *ic_data;
struct regmap_config regmap_config;
struct regmap *regmap;
size_t max_size;
int error = 0;

+ ic_data = spi_get_device_match_data(spi);
+ if (!ic_data)
+ return -ENODATA;
+
spi->mode = SPI_MODE_0;
spi->bits_per_word = 8;
error = spi_setup(spi);
--
2.34.1