]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntb: Constify struct bus_type
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 20 Jul 2024 10:59:36 +0000 (12:59 +0200)
committerJon Mason <jdmason@kudzu.us>
Fri, 20 Sep 2024 14:50:38 +0000 (10:50 -0400)
'struct bus_type' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text    data     bss     dec     hex filename
  69682    4593     152   74427   122bb drivers/ntb/ntb_transport.o
   5847     448      32    6327    18b7 drivers/ntb/core.o

After:
=====
   text    data     bss     dec     hex filename
  69858    4433     152   74443   122cb drivers/ntb/ntb_transport.o
   6007     288      32    6327    18b7 drivers/ntb/core.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
drivers/ntb/core.c
drivers/ntb/ntb_transport.c

index d702bee7808266e3ee04fd49a2c157a3413bc9b2..ed6f4adc613033f93955e6b3f2cba7bcd47400e9 100644 (file)
@@ -72,7 +72,7 @@ MODULE_VERSION(DRIVER_VERSION);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
 
-static struct bus_type ntb_bus;
+static const struct bus_type ntb_bus;
 static void ntb_dev_release(struct device *dev);
 
 int __ntb_register_client(struct ntb_client *client, struct module *mod,
@@ -298,7 +298,7 @@ static void ntb_dev_release(struct device *dev)
        complete(&ntb->released);
 }
 
-static struct bus_type ntb_bus = {
+static const struct bus_type ntb_bus = {
        .name = "ntb",
        .probe = ntb_probe,
        .remove = ntb_remove,
index 77e55debeed61b206fa76a81b9a568b75e3fed37..a79f68e18d3f51a389235a385efcb3a545c50acb 100644 (file)
@@ -314,7 +314,7 @@ static void ntb_transport_bus_remove(struct device *dev)
        put_device(dev);
 }
 
-static struct bus_type ntb_transport_bus = {
+static const struct bus_type ntb_transport_bus = {
        .name = "ntb_transport",
        .match = ntb_transport_bus_match,
        .probe = ntb_transport_bus_probe,