Commit dcb3a08e authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

Documentation: configfs examples crash fix

When configfs_register_subsystem() fails, we unregister too many
subsystems in configfs_example_init.  Decrement i by one to not unregister
non-registered subsystem.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Joel Becker <joel.becker@oracle.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 02d54f09
...@@ -464,9 +464,8 @@ static int __init configfs_example_init(void) ...@@ -464,9 +464,8 @@ static int __init configfs_example_init(void)
return 0; return 0;
out_unregister: out_unregister:
for (; i >= 0; i--) { for (i--; i >= 0; i--)
configfs_unregister_subsystem(example_subsys[i]); configfs_unregister_subsystem(example_subsys[i]);
}
return ret; return ret;
} }
...@@ -475,9 +474,8 @@ static void __exit configfs_example_exit(void) ...@@ -475,9 +474,8 @@ static void __exit configfs_example_exit(void)
{ {
int i; int i;
for (i = 0; example_subsys[i]; i++) { for (i = 0; example_subsys[i]; i++)
configfs_unregister_subsystem(example_subsys[i]); configfs_unregister_subsystem(example_subsys[i]);
}
} }
module_init(configfs_example_init); module_init(configfs_example_init);
......
...@@ -427,9 +427,8 @@ static int __init configfs_example_init(void) ...@@ -427,9 +427,8 @@ static int __init configfs_example_init(void)
return 0; return 0;
out_unregister: out_unregister:
for (; i >= 0; i--) { for (i--; i >= 0; i--)
configfs_unregister_subsystem(example_subsys[i]); configfs_unregister_subsystem(example_subsys[i]);
}
return ret; return ret;
} }
...@@ -438,9 +437,8 @@ static void __exit configfs_example_exit(void) ...@@ -438,9 +437,8 @@ static void __exit configfs_example_exit(void)
{ {
int i; int i;
for (i = 0; example_subsys[i]; i++) { for (i = 0; example_subsys[i]; i++)
configfs_unregister_subsystem(example_subsys[i]); configfs_unregister_subsystem(example_subsys[i]);
}
} }
module_init(configfs_example_init); module_init(configfs_example_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment