Skip to contentSkip to conversation

sysctl: minor cleanup in new_dir()

PATCH In review Vasily Averin 2 participants 2 messages Apr 24, 2022 – Apr 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysctl: minor cleanup in new_dir()

Byte zeroing is not required here, since memory was allocated by kzalloc()

---
 fs/proc/proc_sysctl.c | 1 -
 1 file changed, 1 deletion(-)
fs/proc/proc_sysctl.c +0 -1
index 7d9cfc730bd4..094c24e010ae 100644
@@ -978,7 +978,6 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
 	table = (struct ctl_table *)(node + 1);
 	new_name = (char *)(table + 2);
 	memcpy(new_name, name, namelen);
-	new_name[namelen] = '\0';
 	table[0].procname = new_name;
 	table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
 	init_header(&new->header, set->dir.header.root, set, node, table);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 12 lines · Vasily Averin

Byte zeroing is not required here, since memory was allocated by kzalloc()

---
 fs/proc/proc_sysctl.c | 1 -
 1 file changed, 1 deletion(-)
fs/proc/proc_sysctl.c +0 -0
index 7d9cfc730bd4..094c24e010ae 100644

fs/proc/proc_sysctl.c static struct ctl_dir *new_dir(struct ctl_table_set *set, · line 983

Quoted 7 lines
fs/proc/proc_sysctl.c +0 -1
@@ -978,7 +978,6 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
 	table = (struct ctl_table *)(node + 1);
 	new_name = (char *)(table + 2);
 	memcpy(new_name, name, namelen);
-	new_name[namelen] = '\0';
 	table[0].procname = new_name;
 	table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
 	init_header(&new->header, set->dir.header.root, set, node, table);

Queued onto sysctl-testing, thanks!

Luis