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] [day] [month] [year] [list]
Message-ID: <2025091212-dole-multitask-ee06@gregkh>
Date: Fri, 12 Sep 2025 13:38:36 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Charles Han <hanchunchao@...pur.com>
Cc: arnd@...db.de, naveenkrishna.chatradhi@....com, akshay.gupta@....com,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] misc: amd-sbi: Add NULL check in create_misc_rmi_device

On Fri, Sep 12, 2025 at 06:14:51PM +0800, Charles Han wrote:
> Add check for the return value of devm_kmemdup() to prevent
> potential null pointer dereference.
> 
> Fixes: 35ac2034db72 ("misc: amd-sbi: Add support for AMD_SBI IOCTL")
> Signed-off-by: Charles Han <hanchunchao@...pur.com>
> ---
>  drivers/misc/amd-sbi/rmi-core.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/misc/amd-sbi/rmi-core.c b/drivers/misc/amd-sbi/rmi-core.c
> index 3dec2fc00124..50b8e9e02833 100644
> --- a/drivers/misc/amd-sbi/rmi-core.c
> +++ b/drivers/misc/amd-sbi/rmi-core.c
> @@ -471,6 +471,9 @@ int create_misc_rmi_device(struct sbrmi_data *data,
>  							 GFP_KERNEL,
>  							 "sbrmi-%x",
>  							 data->dev_static_addr);
> +	if (!data->sbrmi_misc_dev.name)
> +		return -ENOMEM;
> +
>  	data->sbrmi_misc_dev.minor	= MISC_DYNAMIC_MINOR;
>  	data->sbrmi_misc_dev.fops	= &sbrmi_fops;
>  	data->sbrmi_misc_dev.parent	= dev;
> @@ -478,6 +481,9 @@ int create_misc_rmi_device(struct sbrmi_data *data,
>  							 GFP_KERNEL,
>  							 "sbrmi-%x",
>  							 data->dev_static_addr);
> +	if (!data->sbrmi_misc_dev.nodename)
> +		return -ENOMEM;
> +

Why not just make this a single if statement?  And this really can't
ever fail in real life :)

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ