Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 7c3f042

Browse files
nunojsagregkh
authored andcommitted
Input: adp5589-keys - fix NULL pointer dereference
commit fb5cc65 upstream. 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: 30df385 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cda7d59 commit 7c3f042

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

drivers/input/keyboard/adp5589-keys.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,9 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, unsigned int revid)
936936

937937
static void adp5589_clear_config(void *data)
938938
{
939-
struct i2c_client *client = data;
940-
struct adp5589_kpad *kpad = i2c_get_clientdata(client);
939+
struct adp5589_kpad *kpad = data;
941940

942-
adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0);
941+
adp5589_write(kpad->client, kpad->var->reg(ADP5589_GENERAL_CFG), 0);
943942
}
944943

945944
static int adp5589_probe(struct i2c_client *client)
@@ -983,7 +982,7 @@ static int adp5589_probe(struct i2c_client *client)
983982
}
984983

985984
error = devm_add_action_or_reset(&client->dev, adp5589_clear_config,
986-
client);
985+
kpad);
987986
if (error)
988987
return error;
989988

@@ -1010,8 +1009,6 @@ static int adp5589_probe(struct i2c_client *client)
10101009
if (error)
10111010
return error;
10121011

1013-
i2c_set_clientdata(client, kpad);
1014-
10151012
dev_info(&client->dev, "Rev.%d keypad, irq %d\n", revid, client->irq);
10161013
return 0;
10171014
}

0 commit comments

Comments
 (0)