public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: amd-sbi: Add NULL check in create_misc_rmi_device
@ 2025-09-12 10:14 Charles Han
  2025-09-12 11:38 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Han @ 2025-09-12 10:14 UTC (permalink / raw)
  To: arnd, gregkh, naveenkrishna.chatradhi, akshay.gupta
  Cc: linux-kernel, Charles Han

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@inspur.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;
+
 	data->sbrmi_misc_dev.mode	= 0600;
 
 	return misc_register(&data->sbrmi_misc_dev);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-12 11:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 10:14 [PATCH] misc: amd-sbi: Add NULL check in create_misc_rmi_device Charles Han
2025-09-12 11:38 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox