All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe()
@ 2025-04-01 13:34 Henry Martin
  2025-04-01 13:39 ` Greg KH
  2025-04-15 14:13 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Henry Martin @ 2025-04-01 13:34 UTC (permalink / raw)
  To: arnd, gregkh; +Cc: linux-kernel, Henry Martin

devm_kasprintf() returns NULL when memory allocation fails. Currently,
tps6594_pfsm_probe() does not check for this case, which results in a
NULL pointer dereference.

Add NULL check after devm_kasprintf() to prevent this issue.

Fixes: a0df3ef087f8 ("misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
 drivers/misc/tps6594-pfsm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
index 0a24ce44cc37..0d9dad20b6ae 100644
--- a/drivers/misc/tps6594-pfsm.c
+++ b/drivers/misc/tps6594-pfsm.c
@@ -281,6 +281,8 @@ static int tps6594_pfsm_probe(struct platform_device *pdev)
 	pfsm->miscdev.minor = MISC_DYNAMIC_MINOR;
 	pfsm->miscdev.name = devm_kasprintf(dev, GFP_KERNEL, "pfsm-%ld-0x%02x",
 					    tps->chip_id, tps->reg);
+	if (!pfsm->miscdev.name)
+		return -ENOMEM;
 	pfsm->miscdev.fops = &tps6594_pfsm_fops;
 	pfsm->miscdev.parent = dev->parent;
 	pfsm->chip_id = tps->chip_id;
-- 
2.34.1


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

end of thread, other threads:[~2025-04-15 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 13:34 [PATCH v1] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe() Henry Martin
2025-04-01 13:39 ` Greg KH
2025-04-15 14:13 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.