kunit: Fix the wrong err path and add goto labels in kunit_filter_suites()
authorJinjie Ruan <ruanjinjie@huawei.com>
Sun, 3 Sep 2023 07:10:26 +0000 (15:10 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Tue, 5 Sep 2023 18:29:55 +0000 (12:29 -0600)
commit4b00920da1dd2bbb33baeb2e7b9808af4c68de97
tree1613042f4302bb1d7617c0766592997cfae2278c
parent2810c1e99867a811e631dd24e63e6c1e3b78a59d
kunit: Fix the wrong err path and add goto labels in kunit_filter_suites()

Take the last kfree(parsed_filters) and add it to be the first. Take
the first kfree(copy) and add it to be the last. The Best practice is to
return these errors reversely.

And as David suggested, add several labels which target only the things
which actually have been allocated so far.

Fixes: 529534e8cba3 ("kunit: Add ability to filter attributes")
Fixes: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Rae Moar <rmoar@google.com>
Suggested-by: David Gow <davidgow@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
lib/kunit/executor.c