Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit aef9d25

Browse files
committed
sysctl: Remove superfluous empty allocations from sysctl internals
Now that the sentinels have been removed from ctl_table arrays, there is no need to artificially append empty ctl_table elements at ctl_table registration. Remove superfluous empty allocation from new_dir and new_links. Signed-off-by: Joel Granados <j.granados@samsung.com>
1 parent 55bb7eb commit aef9d25

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/proc/proc_sysctl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,14 +949,14 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
949949
char *new_name;
950950

951951
new = kzalloc(sizeof(*new) + sizeof(struct ctl_node) +
952-
sizeof(struct ctl_table)*2 + namelen + 1,
952+
sizeof(struct ctl_table) + namelen + 1,
953953
GFP_KERNEL);
954954
if (!new)
955955
return NULL;
956956

957957
node = (struct ctl_node *)(new + 1);
958958
table = (struct ctl_table *)(node + 1);
959-
new_name = (char *)(table + 2);
959+
new_name = (char *)(table + 1);
960960
memcpy(new_name, name, namelen);
961961
table[0].procname = new_name;
962962
table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO;
@@ -1175,7 +1175,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
11751175

11761176
links = kzalloc(sizeof(struct ctl_table_header) +
11771177
sizeof(struct ctl_node)*head->ctl_table_size +
1178-
sizeof(struct ctl_table)*(head->ctl_table_size + 1) +
1178+
sizeof(struct ctl_table)*head->ctl_table_size +
11791179
name_bytes,
11801180
GFP_KERNEL);
11811181

@@ -1184,7 +1184,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
11841184

11851185
node = (struct ctl_node *)(links + 1);
11861186
link_table = (struct ctl_table *)(node + head->ctl_table_size);
1187-
link_name = (char *)&link_table[head->ctl_table_size + 1];
1187+
link_name = (char *)(link_table + head->ctl_table_size);
11881188
link = link_table;
11891189

11901190
list_for_each_table_entry(entry, head) {

0 commit comments

Comments
 (0)