1 From 2c258d357ce76a397e991d1d4be5d8747239bae1 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Thu, 18 Jan 2024 11:37:59 -0800
4 Subject: Input: synaptics-rmi4 - fail probing if memory allocation for "phys"
7 From: Kunwu Chan <chentao@kylinos.cn>
9 [ Upstream commit bc4996184d56cfaf56d3811ac2680c8a0e2af56e ]
11 While input core can work with input->phys set to NULL userspace might
12 depend on it, so better fail probing if allocation fails. The system must
13 be in a pretty bad shape for it to happen anyway.
15 Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
16 Link: https://lore.kernel.org/r/20240117073124.143636-1-chentao@kylinos.cn
17 Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
18 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 drivers/input/rmi4/rmi_driver.c | 6 +++++-
21 1 file changed, 5 insertions(+), 1 deletion(-)
23 diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
24 index 258d5fe3d395c..aa32371f04af6 100644
25 --- a/drivers/input/rmi4/rmi_driver.c
26 +++ b/drivers/input/rmi4/rmi_driver.c
27 @@ -1196,7 +1196,11 @@ static int rmi_driver_probe(struct device *dev)
29 rmi_driver_set_input_params(rmi_dev, data->input);
30 data->input->phys = devm_kasprintf(dev, GFP_KERNEL,
31 - "%s/input0", dev_name(dev));
32 + "%s/input0", dev_name(dev));
33 + if (!data->input->phys) {
39 retval = rmi_init_functions(data);