[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <edbe125df73698f44e6c0697b7c45dc5acb2d455.1693431144.git.mirq-linux@rere.qmqm.pl>
Date: Wed, 30 Aug 2023 23:38:57 +0200
From: Michał Mirosław <mirq-linux@...e.qmqm.pl>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 8/9] regulator/core: set_consumer_device_supply: avoid copying
const data
As consumer_dev_name might as well be const, don't copy it if not
required.
Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
drivers/regulator/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7c4ba090d88d..8ab4de7cadcb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1735,7 +1735,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
new_node->supply = supply;
if (consumer_dev_name != NULL) {
- new_node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
+ new_node->dev_name = kstrdup_const(consumer_dev_name, GFP_KERNEL);
if (new_node->dev_name == NULL) {
kfree(new_node);
return -ENOMEM;
@@ -1770,7 +1770,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
fail:
mutex_unlock(®ulator_list_mutex);
- kfree(new_node->dev_name);
+ kfree_const(new_node->dev_name);
kfree(new_node);
return -EBUSY;
}
@@ -1782,7 +1782,7 @@ static void unset_regulator_supplies(struct regulator_dev *rdev)
list_for_each_entry_safe(node, n, ®ulator_map_list, list) {
if (rdev == node->regulator) {
list_del(&node->list);
- kfree(node->dev_name);
+ kfree_const(node->dev_name);
kfree(node);
}
}
--
2.39.2
Powered by blists - more mailing lists