Skip to contentSkip to conversation

proc/proc_sysctl: Modify the order of scheduling function calls

PATCH In review Li zeming 2 participants 2 messages Sep 5, 2022

Subsystems (3)
lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 proc/proc_sysctl: Modify the order of scheduling function calls

When the ctl_table_header object is judged to be valid, the scheduling check is performed again.

---
 fs/proc/proc_sysctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/proc/proc_sysctl.c +1 -2
index 50ba9e4fb284..36921e2ebeb0 100644
@@ -1729,11 +1729,10 @@ static void drop_sysctl_table(struct ctl_table_header *header)
 void unregister_sysctl_table(struct ctl_table_header * header)
 {
 	int nr_subheaders;
-	might_sleep();
-
 	if (header == NULL)
 		return;
 
+	might_sleep();
 	nr_subheaders = count_subheaders(header->ctl_table_arg);
 	if (unlikely(nr_subheaders > 1)) {
 		struct ctl_table_header **subheaders;
Signature · 1 line
2.18.2
#1 lore raw
Quoted 2 lines · Li zeming

When the ctl_table_header object is judged to be valid, the scheduling check is performed again.

No, we want the check in all cases, even if the header is NULL.

Quoted 25 lines
---
 fs/proc/proc_sysctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/proc/proc_sysctl.c +1 -2
index 50ba9e4fb284..36921e2ebeb0 100644
@@ -1729,11 +1729,10 @@ static void drop_sysctl_table(struct ctl_table_header *header)
 void unregister_sysctl_table(struct ctl_table_header * header)
 {
 	int nr_subheaders;
-	might_sleep();
-
 	if (header == NULL)
 		return;
 
+	might_sleep();
 	nr_subheaders = count_subheaders(header->ctl_table_arg);
 	if (unlikely(nr_subheaders > 1)) {
 		struct ctl_table_header **subheaders;
Signature · 1 line
2.18.2