[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241118095939.49612-1-hanchunchao@inspur.com>
Date: Mon, 18 Nov 2024 17:59:39 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <djakov@...nel.org>
CC: <linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Charles Han
<hanchunchao@...pur.com>
Subject: [PATCH] interconnect: Add NULL check in icc_clk_register
devm_kasprintf() can return a NULL pointer on failure,but this
returned value in icc_clk_register() is not checked.
Add NULL check in icc_clk_register(), to handle kernel NULL
pointer dereference error.
Fixes: 0ac2a08f42ce ("interconnect: add clk-based icc provider support")
Signed-off-by: Charles Han <hanchunchao@...pur.com>
---
drivers/interconnect/icc-clk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/interconnect/icc-clk.c b/drivers/interconnect/icc-clk.c
index b956e4050f38..e4188cc5b892 100644
--- a/drivers/interconnect/icc-clk.c
+++ b/drivers/interconnect/icc-clk.c
@@ -116,6 +116,9 @@ struct icc_provider *icc_clk_register(struct device *dev,
}
node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_master", data[i].name);
+ if (!node->name)
+ return -ENOMEM;
+
node->data = &qp->clocks[i];
icc_node_add(node, provider);
/* link to the next node, slave */
@@ -129,6 +132,9 @@ struct icc_provider *icc_clk_register(struct device *dev,
}
node->name = devm_kasprintf(dev, GFP_KERNEL, "%s_slave", data[i].name);
+ if (!node->name)
+ return -ENOMEM;
+
/* no data for slave node */
icc_node_add(node, provider);
onecell->nodes[j++] = node;
--
2.31.1
Powered by blists - more mailing lists