Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: adp5589-keys - fix NULL pointer dereference

We register a devm action to call adp5589_clear_config() and then pass
the i2c client as argument so that we can call i2c_get_clientdata() in
order to get our device object. However, i2c_set_clientdata() is only
being set at the end of the probe function which means that we'll get a
NULL pointer dereference in case the probe function fails early.

Fixes: 30df385e35a4 ("Input: adp5589-keys - use devm_add_action_or_reset() for register clear")
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20241001-b4-dev-adp5589-fw-conversion-v1-1-fca0149dfc47@analog.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Nuno Sa and committed by
Dmitry Torokhov
fb5cc65f a3f9a74d

+3 -6
+3 -6
drivers/input/keyboard/adp5589-keys.c
··· 936 936 937 937 static void adp5589_clear_config(void *data) 938 938 { 939 - struct i2c_client *client = data; 940 - struct adp5589_kpad *kpad = i2c_get_clientdata(client); 939 + struct adp5589_kpad *kpad = data; 941 940 942 - adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0); 941 + adp5589_write(kpad->client, kpad->var->reg(ADP5589_GENERAL_CFG), 0); 943 942 } 944 943 945 944 static int adp5589_probe(struct i2c_client *client) ··· 982 983 } 983 984 984 985 error = devm_add_action_or_reset(&client->dev, adp5589_clear_config, 985 - client); 986 + kpad); 986 987 if (error) 987 988 return error; 988 989 ··· 1008 1009 error = adp5589_gpio_add(kpad); 1009 1010 if (error) 1010 1011 return error; 1011 - 1012 - i2c_set_clientdata(client, kpad); 1013 1012 1014 1013 dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq); 1015 1014 return 0;