Author: Julia Lawall <firstname.lastname@example.org>
b_entry_name and buffer are initially NULL, are initialized within a loop
to the result of calling kmalloc, and are freed at the bottom of this loop.
The loop contains gotos to cleanup, which also frees b_entry_name and
buffer. Some of these gotos are before the reinitializations of
b_entry_name and buffer. To maintain the invariant that b_entry_name and
buffer are NULL at the top of the loop, and thus acceptable arguments to
kfree, these variables are now set to NULL after the kfrees.
This seems to be the simplest solution. A more complicated solution
would be to introduce more labels in the error handling code at the end of
A simplified version of the semantic match that finds this problem is as
... when != E = E1
when != I(E,...) S
when != &E
Signed-off-by: Julia Lawall
Signed-off-by: "Theodore Ts'o"
fs/ext4/xattr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 83218be..f3a2f7e 100644
@@ -1332,6 +1332,8 @@ retry:
+ b_entry_name = NULL;
+ buffer = NULL;