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

Commit 55bb7eb

Browse files
committed
sysctl: Replace nr_entries with ctl_table_size in new_links
The number of ctl_table entries (nr_entries) calculation was previously based on the ctl_table_size and the sentinel element. Since the sentinels have been removed, we remove the calculation and just use the ctl_table_size from the ctl_table_header. Signed-off-by: Joel Granados <j.granados@samsung.com>
1 parent d7a76ec commit 55bb7eb

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

fs/proc/proc_sysctl.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,27 +1166,25 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
11661166
struct ctl_table_header *links;
11671167
struct ctl_node *node;
11681168
char *link_name;
1169-
int nr_entries, name_bytes;
1169+
int name_bytes;
11701170

11711171
name_bytes = 0;
1172-
nr_entries = 0;
11731172
list_for_each_table_entry(entry, head) {
1174-
nr_entries++;
11751173
name_bytes += strlen(entry->procname) + 1;
11761174
}
11771175

11781176
links = kzalloc(sizeof(struct ctl_table_header) +
1179-
sizeof(struct ctl_node)*nr_entries +
1180-
sizeof(struct ctl_table)*(nr_entries + 1) +
1177+
sizeof(struct ctl_node)*head->ctl_table_size +
1178+
sizeof(struct ctl_table)*(head->ctl_table_size + 1) +
11811179
name_bytes,
11821180
GFP_KERNEL);
11831181

11841182
if (!links)
11851183
return NULL;
11861184

11871185
node = (struct ctl_node *)(links + 1);
1188-
link_table = (struct ctl_table *)(node + nr_entries);
1189-
link_name = (char *)&link_table[nr_entries + 1];
1186+
link_table = (struct ctl_table *)(node + head->ctl_table_size);
1187+
link_name = (char *)&link_table[head->ctl_table_size + 1];
11901188
link = link_table;
11911189

11921190
list_for_each_table_entry(entry, head) {
@@ -1200,7 +1198,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_
12001198
}
12011199
init_header(links, dir->header.root, dir->header.set, node, link_table,
12021200
head->ctl_table_size);
1203-
links->nreg = nr_entries;
1201+
links->nreg = head->ctl_table_size;
12041202

12051203
return links;
12061204
}

0 commit comments

Comments
 (0)