[PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL
From: Lee Jones
Date: Fri Nov 27 2026 - 15:12:12 EST
goodix_berlin_i2c_probe() passes the pointer returned by
i2c_get_match_data() straight to goodix_berlin_probe(), which
unconditionally dereferences ic_data. If the driver is bound via sysfs
new_device without matching OF or I2C match data, i2c_get_match_data()
returns NULL and causes a NULL pointer dereference.
Return -EINVAL when i2c_get_match_data() returns NULL.
Fixes: 4d395cb071a3 ("Input: goodix_berlin - add support for Berlin-A series")
Closes: https://sashiko.dev/#/bug/linux-59243248-bebc-4f35-8608-d25e5ec38f26
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/input/touchscreen/goodix_berlin_i2c.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/input/touchscreen/goodix_berlin_i2c.c b/drivers/input/touchscreen/goodix_berlin_i2c.c
index 929090a094bf..7c85415ea409 100644
--- a/drivers/input/touchscreen/goodix_berlin_i2c.c
+++ b/drivers/input/touchscreen/goodix_berlin_i2c.c
@@ -36,6 +36,9 @@ static int goodix_berlin_i2c_probe(struct i2c_client *client)
struct regmap *regmap;
int error;
+ if (!ic_data)
+ return -EINVAL;
+
regmap = devm_regmap_init_i2c(client, &goodix_berlin_i2c_regmap_conf);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
--
2.56.1.839.g22a8290db9-goog