lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZabU_lsGCuki1dSY@google.com>
Date: Tue, 16 Jan 2024 11:11:58 -0800
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Kunwu Chan <chentao@...inos.cn>
Cc: aduggan@...aptics.com, cheiny@...aptics.com,
	linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Input: synaptics-rmi4: Fix NULL pointer dereference in
 rmi_driver_probe

On Tue, Jan 16, 2024 at 04:38:47PM +0800, Kunwu Chan wrote:
> 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.

It is perfectly valid to not set "input->phys" and leave it at NULL. So
while I agree that having error handling is good I do not believe
there's chance for NULL pointer dereference, so please adjust your patch
title.

> 
> 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",

No need to log the error here, memory allocation will already log the
failure.

Thanks.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ