Skip to content

Commit 927cc5c

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
ubifs: ubifs_add_orphan: Fix a memory leak bug
Memory leak occurs when files with extended attributes are added to orphan list. Signed-off-by: Zhihao Cheng <[email protected]> Fixes: 988bec4 ("ubifs: orphan: Handle xattrs like files") Signed-off-by: Richard Weinberger <[email protected]>
1 parent 81423c7 commit 927cc5c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/ubifs/orphan.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
157157
int err = 0;
158158
ino_t xattr_inum;
159159
union ubifs_key key;
160-
struct ubifs_dent_node *xent;
160+
struct ubifs_dent_node *xent, *pxent = NULL;
161161
struct fscrypt_name nm = {0};
162162
struct ubifs_orphan *xattr_orphan;
163163
struct ubifs_orphan *orphan;
@@ -181,11 +181,16 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
181181
xattr_inum = le64_to_cpu(xent->inum);
182182

183183
xattr_orphan = orphan_add(c, xattr_inum, orphan);
184-
if (IS_ERR(xattr_orphan))
184+
if (IS_ERR(xattr_orphan)) {
185+
kfree(xent);
185186
return PTR_ERR(xattr_orphan);
187+
}
186188

189+
kfree(pxent);
190+
pxent = xent;
187191
key_read(c, &xent->key, &key);
188192
}
193+
kfree(pxent);
189194

190195
return 0;
191196
}

0 commit comments

Comments
 (0)