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
| ||
|
Date: Sun, 4 Oct 2020 21:32:02 +0200 From: Rikard Falkeborn <rikard.falkeborn@...il.com> To: Greg Kroah-Hartman <gregkh@...uxfoundation.org> Cc: linux-kernel@...r.kernel.org, Rikard Falkeborn <rikard.falkeborn@...il.com>, Sebastian Reichel <sre@...nel.org>, linux-pm@...r.kernel.org Subject: [PATCH 3/3] power: supply: Constify static w1_family_ops structs The only usage of these structs is to assign their address to the fops field in the w1_family struct, which is a const pointer. Make them const to allow the compiler to put them in read-only memory. This was done with the following Coccinelle semantic patch (http://coccinelle.lip6.fr/): // <smpl> @r1 disable optional_qualifier @ identifier i; position p; @@ static struct w1_family_ops i@p = {...}; @ok1@ identifier r1.i; position p; identifier s; @@ static struct w1_family s = { .fops=&i@p, }; @bad1@ position p!={r1.p,ok1.p}; identifier r1.i; @@ i@p @depends on !bad1 disable optional_qualifier@ identifier r1.i; @@ static +const struct w1_family_ops i={}; // </smpl> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@...il.com> --- drivers/power/supply/bq27xxx_battery_hdq.c | 2 +- drivers/power/supply/ds2760_battery.c | 2 +- drivers/power/supply/max1721x_battery.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/bq27xxx_battery_hdq.c b/drivers/power/supply/bq27xxx_battery_hdq.c index 12b10dad77d3..922759ab2e04 100644 --- a/drivers/power/supply/bq27xxx_battery_hdq.c +++ b/drivers/power/supply/bq27xxx_battery_hdq.c @@ -97,7 +97,7 @@ static void bq27xxx_battery_hdq_remove_slave(struct w1_slave *sl) bq27xxx_battery_teardown(di); } -static struct w1_family_ops bq27xxx_battery_hdq_fops = { +static const struct w1_family_ops bq27xxx_battery_hdq_fops = { .add_slave = bq27xxx_battery_hdq_add_slave, .remove_slave = bq27xxx_battery_hdq_remove_slave, }; diff --git a/drivers/power/supply/ds2760_battery.c b/drivers/power/supply/ds2760_battery.c index 11bed88a89fa..695bb6747400 100644 --- a/drivers/power/supply/ds2760_battery.c +++ b/drivers/power/supply/ds2760_battery.c @@ -795,7 +795,7 @@ static const struct of_device_id w1_ds2760_of_ids[] = { }; #endif -static struct w1_family_ops w1_ds2760_fops = { +static const struct w1_family_ops w1_ds2760_fops = { .add_slave = w1_ds2760_add_slave, .remove_slave = w1_ds2760_remove_slave, .groups = w1_ds2760_groups, diff --git a/drivers/power/supply/max1721x_battery.c b/drivers/power/supply/max1721x_battery.c index 9ca895b0dabb..1b1a36f8e929 100644 --- a/drivers/power/supply/max1721x_battery.c +++ b/drivers/power/supply/max1721x_battery.c @@ -431,7 +431,7 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl) return 0; } -static struct w1_family_ops w1_max1721x_fops = { +static const struct w1_family_ops w1_max1721x_fops = { .add_slave = devm_w1_max1721x_add_device, }; -- 2.28.0
Powered by blists - more mailing lists