Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: fix reference leaks in f2fs_acl_create

Our f2fs_acl_create is copied and modified from posix_acl_create to avoid
deadlock bug when inline_dentry feature is enabled.

Now, we got reference leaks in posix_acl_create, and this has been fixed in
commit fed0b588be2f ("posix_acl: fix reference leaks in posix_acl_create")
by Omar Sandoval.
https://lkml.org/lkml/2015/2/9/5

Let's fix this issue in f2fs_acl_create too.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Reviewed-by: Changman Lee <cm224.lee@ssamsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Chao Yu and committed by
Jaegeuk Kim
83dfe53c bda19076

+9 -5
+9 -5
fs/f2fs/acl.c
··· 351 351 352 352 *acl = f2fs_acl_clone(p, GFP_NOFS); 353 353 if (!*acl) 354 - return -ENOMEM; 354 + goto no_mem; 355 355 356 356 ret = f2fs_acl_create_masq(*acl, mode); 357 - if (ret < 0) { 358 - posix_acl_release(*acl); 359 - return -ENOMEM; 360 - } 357 + if (ret < 0) 358 + goto no_mem_clone; 361 359 362 360 if (ret == 0) { 363 361 posix_acl_release(*acl); ··· 376 378 *default_acl = NULL; 377 379 *acl = NULL; 378 380 return 0; 381 + 382 + no_mem_clone: 383 + posix_acl_release(*acl); 384 + no_mem: 385 + posix_acl_release(p); 386 + return -ENOMEM; 379 387 } 380 388 381 389 int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,