[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240116083847.89934-1-chentao@kylinos.cn>
Date: Tue, 16 Jan 2024 16:38:47 +0800
From: Kunwu Chan <chentao@...inos.cn>
To: dmitry.torokhov@...il.com,
aduggan@...aptics.com,
cheiny@...aptics.com
Cc: linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org,
Kunwu Chan <chentao@...inos.cn>
Subject: [PATCH] Input: synaptics-rmi4: Fix NULL pointer dereference in rmi_driver_probe
devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure. Ensure the allocation was successful
by checking the pointer validity.
Fixes: 2b6a321da9a2 ("Input: synaptics-rmi4 - add support for Synaptics RMI4 devices")
Signed-off-by: Kunwu Chan <chentao@...inos.cn>
---
drivers/input/rmi4/rmi_driver.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 258d5fe3d395..d3a601ff51e6 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -1197,6 +1197,12 @@ static int rmi_driver_probe(struct device *dev)
rmi_driver_set_input_params(rmi_dev, data->input);
data->input->phys = devm_kasprintf(dev, GFP_KERNEL,
"%s/input0", dev_name(dev));
+ if (!data->input->phys) {
+ dev_err(dev, "%s: Failed to allocate memory.\n",
+ __func__);
+ retval = -ENOMEM;
+ goto err;
+ }
}
retval = rmi_init_functions(data);
--
2.39.2
Powered by blists - more mailing lists