mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] arcnet: Add NULL check in com20020pci_probe()
@ 2025-04-01 13:49 Henry Martin
  2025-04-01 14:36 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Henry Martin @ 2025-04-01 13:49 UTC (permalink / raw)
  To: m.grzeschik, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Henry Martin

devm_kasprintf() returns NULL when memory allocation fails. Currently,
com20020pci_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: 6b17a597fc2f ("arcnet: restoring support for multiple Sohard Arcnet cards")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
 drivers/net/arcnet/com20020-pci.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index c5e571ec94c9..65c6fab0e359 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -264,6 +264,13 @@ static int com20020pci_probe(struct pci_dev *pdev,
 							"pci:red:recon:%d-%d",
 							dev->dev_id, i);
 			card->recon_led.dev = &dev->dev;
+			if (!card->tx_led.default_trigger ||
+			    !card->tx_led.name ||
+			    !card->recon_led.default_trigger ||
+			    !card->recon_led.name) {
+				ret = -ENOMEM;
+				goto err_free_arcdev;
+			}
 
 			ret = devm_led_classdev_register(&pdev->dev, &card->tx_led);
 			if (ret)
-- 
2.34.1


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-01 13:49 [PATCH v1] arcnet: Add NULL check in com20020pci_probe() Henry Martin
2025-04-01 14:36 ` Andrew Lunn

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

all inboxes | Powered by JetHome®