Skip to content

Commit

Permalink
[JFFS2][XATTR] Fix memory leak in POSIX-ACL support
Browse files Browse the repository at this point in the history
jffs2_clear_acl() which releases acl caches allocated by kmalloc()
was defined but it was never called. Thus, we faced to the risk
of memory leaking.

This patch plugs jffs2_clear_acl() into jffs2_do_clear_inode().
It ensures to release acl cache when inode is cleared.

Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
KaiGai Kohei authored and David Woodhouse committed Jul 2, 2006
1 parent c05d52c commit c7afb0f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions fs/jffs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,8 @@ int jffs2_init_acl(struct inode *inode, struct inode *dir)
return rc;
}

void jffs2_clear_acl(struct inode *inode)
void jffs2_clear_acl(struct jffs2_inode_info *f)
{
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);

if (f->i_acl_access && f->i_acl_access != JFFS2_ACL_NOT_CACHED) {
posix_acl_release(f->i_acl_access);
f->i_acl_access = JFFS2_ACL_NOT_CACHED;
Expand Down
4 changes: 2 additions & 2 deletions fs/jffs2/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct jffs2_acl_header {
extern int jffs2_permission(struct inode *, int, struct nameidata *);
extern int jffs2_acl_chmod(struct inode *);
extern int jffs2_init_acl(struct inode *, struct inode *);
extern void jffs2_clear_acl(struct inode *);
extern void jffs2_clear_acl(struct jffs2_inode_info *);

extern struct xattr_handler jffs2_acl_access_xattr_handler;
extern struct xattr_handler jffs2_acl_default_xattr_handler;
Expand All @@ -40,6 +40,6 @@ extern struct xattr_handler jffs2_acl_default_xattr_handler;
#define jffs2_permission NULL
#define jffs2_acl_chmod(inode) (0)
#define jffs2_init_acl(inode,dir) (0)
#define jffs2_clear_acl(inode)
#define jffs2_clear_acl(f)

#endif /* CONFIG_JFFS2_FS_POSIX_ACL */
1 change: 1 addition & 0 deletions fs/jffs2/readinode.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)
struct jffs2_full_dirent *fd, *fds;
int deleted;

jffs2_clear_acl(f);
jffs2_xattr_delete_inode(c, f->inocache);
down(&f->sem);
deleted = f->inocache && !f->inocache->nlink;
Expand Down

0 comments on commit c7afb0f

Please sign in to comment.