From: Charles Han <hanchunchao@inspur.com>
To: <m.grzeschik@pengutronix.de>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<liuyanming@ieisystem.com>, Charles Han <hanchunchao@inspur.com>
Subject: [PATCH] arcnet: com20020-pci:Check devm_kasprintf() returned value
Date: Wed, 28 Aug 2024 14:19:41 +0800 [thread overview]
Message-ID: <20240828061941.8173-1-hanchunchao@inspur.com> (raw)
devm_kasprintf() can return a NULL pointer on failure but this returned
value is not checked.
Fix this lack and check the returned value.
Fixes: 8890624a4e8c ("arcnet: com20020-pci: add led trigger support")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
drivers/net/arcnet/com20020-pci.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index c5e571ec94c9..ca393f9658e9 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -254,6 +254,10 @@ static int com20020pci_probe(struct pci_dev *pdev,
card->tx_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
"pci:green:tx:%d-%d",
dev->dev_id, i);
+ if (!card->tx_led.default_trigger || !card->tx_led.name) {
+ ret = -ENOMEM;
+ goto err_free_arcdev;
+ }
card->tx_led.dev = &dev->dev;
card->recon_led.brightness_set = led_recon_set;
@@ -263,6 +267,11 @@ static int com20020pci_probe(struct pci_dev *pdev,
card->recon_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
"pci:red:recon:%d-%d",
dev->dev_id, i);
+ if (!card->recon_led.default_trigger || !card->recon_led.name) {
+ ret = -ENOMEM;
+ goto err_free_arcdev;
+ }
+
card->recon_led.dev = &dev->dev;
ret = devm_led_classdev_register(&pdev->dev, &card->tx_led);
--
2.31.1
next reply other threads:[~2024-08-28 6:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 6:19 Charles Han [this message]
2024-08-28 15:07 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240828061941.8173-1-hanchunchao@inspur.com \
--to=hanchunchao@inspur.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyanming@ieisystem.com \
--cc=m.grzeschik@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®