* [PATCH] posix_acl: fix memleak when set posix acl.
@ 2019-11-26 8:50 Zhang Xiaoxu
0 siblings, 0 replies; only message in thread
From: Zhang Xiaoxu @ 2019-11-26 8:50 UTC (permalink / raw)
To: viro, linux-fsdevel, zhangxiaoxu5
When set posix acl, it maybe call posix_acl_update_mode in some
filesystem, eg. ext4. It may set acl to NULL, so, we can't free
the acl which allocated in posix_acl_xattr_set.
Use an temp value to store the acl address for posix_acl_release.
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
---
fs/posix_acl.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 84ad1c90d535..b90902d7e6ad 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -882,7 +882,7 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
const char *name, const void *value,
size_t size, int flags)
{
- struct posix_acl *acl = NULL;
+ struct posix_acl *acl = NULL, *p = NULL;
int ret;
if (value) {
@@ -890,8 +890,13 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
if (IS_ERR(acl))
return PTR_ERR(acl);
}
+
+ /* when call set_posix_acl, posix_acl_update_mode may set acl to NULL,
+ use temporary variables p for posix_acl_release. */
+ p = acl;
ret = set_posix_acl(inode, handler->flags, acl);
- posix_acl_release(acl);
+
+ posix_acl_release(p);
return ret;
}
--
2.17.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-11-26 8:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-26 8:50 [PATCH] posix_acl: fix memleak when set posix acl Zhang Xiaoxu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).