Skip to content

Commit 35c87cb

Browse files
tititiou36jonmason
authored andcommitted
ntb: Constify struct bus_type
'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 <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent 1501ae7 commit 35c87cb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/ntb/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ MODULE_VERSION(DRIVER_VERSION);
7272
MODULE_AUTHOR(DRIVER_AUTHOR);
7373
MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
7474

75-
static struct bus_type ntb_bus;
75+
static const struct bus_type ntb_bus;
7676
static void ntb_dev_release(struct device *dev);
7777

7878
int __ntb_register_client(struct ntb_client *client, struct module *mod,
@@ -298,7 +298,7 @@ static void ntb_dev_release(struct device *dev)
298298
complete(&ntb->released);
299299
}
300300

301-
static struct bus_type ntb_bus = {
301+
static const struct bus_type ntb_bus = {
302302
.name = "ntb",
303303
.probe = ntb_probe,
304304
.remove = ntb_remove,

drivers/ntb/ntb_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static void ntb_transport_bus_remove(struct device *dev)
314314
put_device(dev);
315315
}
316316

317-
static struct bus_type ntb_transport_bus = {
317+
static const struct bus_type ntb_transport_bus = {
318318
.name = "ntb_transport",
319319
.match = ntb_transport_bus_match,
320320
.probe = ntb_transport_bus_probe,

0 commit comments

Comments
 (0)