All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe
@ 2025-04-10 11:39 Charles Han
  2025-04-10 11:51 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Charles Han @ 2025-04-10 11:39 UTC (permalink / raw)
  To: arnd, gregkh, jpanis; +Cc: linux-kernel, Charles Han

devm_kasprintf() can return a NULL pointer on failure,but this
returned value in tps6594_pfsm_probe() is not checked.
Add NULL check in tps6594_pfsm_probe(), to handle kernel NULL
pointer dereference error.

Fixes: a0df3ef087f8 ("misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
 drivers/misc/tps6594-pfsm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/misc/tps6594-pfsm.c b/drivers/misc/tps6594-pfsm.c
index 0a24ce44cc37..6db1c9d48f8f 100644
--- a/drivers/misc/tps6594-pfsm.c
+++ b/drivers/misc/tps6594-pfsm.c
@@ -281,6 +281,9 @@ 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.43.0


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

end of thread, other threads:[~2025-04-10 11:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-10 11:39 [PATCH V2] misc: tps6594-pfsm: Add NULL check in tps6594_pfsm_probe Charles Han
2025-04-10 11:51 ` 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.