Skip to content

Commit

Permalink
lib/test_kmod.c: potential double free in error handling
Browse files Browse the repository at this point in the history
There is a copy and paste bug so we set "config->test_driver" to NULL
twice instead of setting "config->test_fs".  Smatch complains that it
leads to a double free:

  lib/test_kmod.c:840 __kmod_config_init() warn: 'config->test_fs' double freed

Link: http://lkml.kernel.org/r/20190121140011.GA14283@kadam
Fixes: d9c6a72 ("kmod: add test driver to stress test the module loader")
Signed-off-by: Dan Carpenter <[email protected]>
Acked-by: Luis Chamberlain <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dan Carpenter authored and torvalds committed Feb 1, 2019
1 parent cefc7ef commit db7ddea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/test_kmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ static void __kmod_config_free(struct test_config *config)
config->test_driver = NULL;

kfree_const(config->test_fs);
config->test_driver = NULL;
config->test_fs = NULL;
}

static void kmod_config_free(struct kmod_test_device *test_dev)
Expand Down

0 comments on commit db7ddea

Please sign in to comment.