[PATCH] perf: Constify struct bus_type

Christophe JAILLET posted 1 patch 1 year, 4 months ago
kernel/events/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] perf: Constify struct bus_type
Posted by Christophe JAILLET 1 year, 4 months ago
'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
 273314	  16956	    716	 290986	  470aa	kernel/events/core.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
 273474	  16764	    716	 290954	  4708a	kernel/events/core.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only.
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index af2e3a06b239..ee011a967a33 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -11508,7 +11508,7 @@ static const struct attribute_group *pmu_dev_groups[] = {
 };
 
 static int pmu_bus_running;
-static struct bus_type pmu_bus = {
+static const struct bus_type pmu_bus = {
 	.name		= "event_source",
 	.dev_groups	= pmu_dev_groups,
 };
-- 
2.45.2