Skip to content

Commit

Permalink
Documentation: configfs examples crash fix
Browse files Browse the repository at this point in the history
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: Jiri Slaby <jslaby@suse.cz>
Cc: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jiri Slaby authored and Linus Torvalds committed May 27, 2011
1 parent 02d54f0 commit dcb3a08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,8 @@ static int __init configfs_example_init(void)
return 0;

out_unregister:
for (; i >= 0; i--) {
for (i--; i >= 0; i--)
configfs_unregister_subsystem(example_subsys[i]);
}

return ret;
}
Expand All @@ -475,9 +474,8 @@ static void __exit configfs_example_exit(void)
{
int i;

for (i = 0; example_subsys[i]; i++) {
for (i = 0; example_subsys[i]; i++)
configfs_unregister_subsystem(example_subsys[i]);
}
}

module_init(configfs_example_init);
Expand Down
6 changes: 2 additions & 4 deletions Documentation/filesystems/configfs/configfs_example_macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,8 @@ static int __init configfs_example_init(void)
return 0;

out_unregister:
for (; i >= 0; i--) {
for (i--; i >= 0; i--)
configfs_unregister_subsystem(example_subsys[i]);
}

return ret;
}
Expand All @@ -438,9 +437,8 @@ static void __exit configfs_example_exit(void)
{
int i;

for (i = 0; example_subsys[i]; i++) {
for (i = 0; example_subsys[i]; i++)
configfs_unregister_subsystem(example_subsys[i]);
}
}

module_init(configfs_example_init);
Expand Down

0 comments on commit dcb3a08

Please sign in to comment.