[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231211024549.231417-1-chentao@kylinos.cn>
Date: Mon, 11 Dec 2023 10:45:49 +0800
From: Kunwu Chan <chentao@...inos.cn>
To: andrew@...n.ch, f.fainelli@...il.com, olteanv@...il.com,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Kunwu Chan <chentao@...inos.cn>,
Kunwu Chan <kunwu.chan@...mail.com>
Subject: [PATCH] net: dsa: vsc73xx: Add null pointer check to vsc73xx_gpio_probe
devm_kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.
Cc: Kunwu Chan <kunwu.chan@...mail.com>
Signed-off-by: Kunwu Chan <chentao@...inos.cn>
---
drivers/net/dsa/vitesse-vsc73xx-core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index e6f29e4e508c..f136eb5aea69 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -1135,6 +1135,10 @@ static int vsc73xx_gpio_probe(struct vsc73xx *vsc)
vsc->gc.label = devm_kasprintf(vsc->dev, GFP_KERNEL, "VSC%04x",
vsc->chipid);
+ if (!vsc->gc.label) {
+ dev_err(vsc->dev, "Fail to allocate memory\n");
+ return -ENOMEM;
+ }
vsc->gc.ngpio = 4;
vsc->gc.owner = THIS_MODULE;
vsc->gc.parent = vsc->dev;
--
2.39.2
Powered by blists - more mailing lists