Skip to contentSkip to conversation

tty: mark ctl_table as const

PATCH In review Luis Felipe Hernandez 1 participant 2 messages Dec 15, 2024 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: mark ctl_table as const

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows struct ctl_table variables to be placed into read-only memory.

tty_table is registered as a sysctl table and should be treated as read-only. By declaring the tty_table structure as const, we ensure that it cannot be accidentally modified at runtime. This change improves safety and aligns with the recommendation from commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table").

---
 drivers/tty/tty_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +1 -1
index dcb1769c3625cd0f7d1555260adfe6051139a305..0e84677712b4e1eb72f209c4d9c54a940b3a9041 100644
@@ -3618,7 +3618,7 @@ void console_sysfs_notify(void)
 		sysfs_notify(&consdev->kobj, NULL, "active");
 }
 
-static struct ctl_table tty_table[] = {
+static const struct ctl_table tty_table[] = {
 	{
 		.procname	= "legacy_tiocsti",
 		.data		= &tty_legacy_tiocsti,

---
base-commit: 535a07698b8b3e6f305673102d297262cae2360a
change-id: 20241206-tty-sysctl-const-2e4b37b1875b

Best regards,

Signature · 1 line
Luis Felipe Hernandez <[email protected]>
#1 lore raw
Quoted 3 lines · Luis Felipe Hernandez

Since commit 7abc9b53bd51 ("sysctl: allow registration of const struct ctl_table"), the sysctl registration API allows struct ctl_table variables to be placed into read-only memory.

Please disregard this patch.