lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <a529e64edb81a4795fe0b6480f1e4051bed1b099.1585944770.git.mirq-linux@rere.qmqm.pl>
Date:   Fri, 03 Apr 2020 22:20:31 +0200
From:   Michał Mirosław <mirq-linux@...e.qmqm.pl>
To:     Andrey Smirnov <andrew.smirnov@...il.com>,
        Guenter Roeck <linux@...ck-us.net>,
        Sebastian Reichel <sebastian.reichel@...labora.com>
Cc:     linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: [PATCH v3 02/11] power: charger-manager: don't write through
 desc->properties

psy_desc->properties will become pointer to const.  Avoid writing
through the pointer to enable constification of the tables elsewhere.

Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
v3: initial version
---
 drivers/power/supply/charger-manager.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index 887f5bb879e5..7ecb82107efb 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1425,15 +1425,18 @@ static int cm_init_thermal_data(struct charger_manager *cm,
 		struct power_supply *fuel_gauge)
 {
 	struct charger_desc *desc = cm->desc;
+	enum power_supply_property *props;
 	union power_supply_propval val;
 	int ret;
 
+	props = (void *)cm->charger_psy_desc.properties;
+
 	/* Verify whether fuel gauge provides battery temperature */
 	ret = power_supply_get_property(fuel_gauge,
 					POWER_SUPPLY_PROP_TEMP, &val);
 
 	if (!ret) {
-		cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] =
+		props[cm->charger_psy_desc.num_properties] =
 				POWER_SUPPLY_PROP_TEMP;
 		cm->charger_psy_desc.num_properties++;
 		cm->desc->measure_battery_temp = true;
@@ -1446,7 +1449,7 @@ static int cm_init_thermal_data(struct charger_manager *cm,
 			return PTR_ERR(cm->tzd_batt);
 
 		/* Use external thermometer */
-		cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] =
+		props[cm->charger_psy_desc.num_properties] =
 				POWER_SUPPLY_PROP_TEMP_AMBIENT;
 		cm->charger_psy_desc.num_properties++;
 		cm->desc->measure_battery_temp = true;
@@ -1622,6 +1625,7 @@ static int charger_manager_probe(struct platform_device *pdev)
 	union power_supply_propval val;
 	struct power_supply *fuel_gauge;
 	struct power_supply_config psy_cfg = {};
+	enum power_supply_property *props;
 
 	if (IS_ERR(desc)) {
 		dev_err(&pdev->dev, "No platform data (desc) found\n");
@@ -1717,7 +1721,7 @@ static int charger_manager_probe(struct platform_device *pdev)
 	cm->charger_psy_desc.name = cm->psy_name_buf;
 
 	/* Allocate for psy properties because they may vary */
-	cm->charger_psy_desc.properties =
+	cm->charger_psy_desc.properties = props =
 		devm_kcalloc(&pdev->dev,
 			     ARRAY_SIZE(default_charger_props) +
 				NUM_CHARGER_PSY_OPTIONAL,
@@ -1725,7 +1729,7 @@ static int charger_manager_probe(struct platform_device *pdev)
 	if (!cm->charger_psy_desc.properties)
 		return -ENOMEM;
 
-	memcpy(cm->charger_psy_desc.properties, default_charger_props,
+	memcpy(props, default_charger_props,
 		sizeof(enum power_supply_property) *
 		ARRAY_SIZE(default_charger_props));
 
@@ -1738,14 +1742,14 @@ static int charger_manager_probe(struct platform_device *pdev)
 	}
 	if (!power_supply_get_property(fuel_gauge,
 					  POWER_SUPPLY_PROP_CHARGE_NOW, &val)) {
-		cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] =
+		props[cm->charger_psy_desc.num_properties] =
 				POWER_SUPPLY_PROP_CHARGE_NOW;
 		cm->charger_psy_desc.num_properties++;
 	}
 	if (!power_supply_get_property(fuel_gauge,
 					  POWER_SUPPLY_PROP_CURRENT_NOW,
 					  &val)) {
-		cm->charger_psy_desc.properties[cm->charger_psy_desc.num_properties] =
+		props[cm->charger_psy_desc.num_properties] =
 				POWER_SUPPLY_PROP_CURRENT_NOW;
 		cm->charger_psy_desc.num_properties++;
 	}
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ