Skip to content

Commit

Permalink
Convert jffs2 acl to struct_size
Browse files Browse the repository at this point in the history
Need to tell the compiler that the acl entries follow the acl header.

Signed-off-by: Matthew Wilcox <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
Matthew Wilcox authored and kees committed Jun 12, 2018
1 parent b2303d7 commit a3ac973
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/jffs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
size_t i;

*size = jffs2_acl_size(acl->a_count);
header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL);
header = kmalloc(struct_size(header, a_entries, acl->a_count),
GFP_KERNEL);
if (!header)
return ERR_PTR(-ENOMEM);
header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);
Expand Down
1 change: 1 addition & 0 deletions fs/jffs2/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct jffs2_acl_entry_short {

struct jffs2_acl_header {
jint32_t a_version;
struct jffs2_acl_entry a_entries[];
};

#ifdef CONFIG_JFFS2_FS_POSIX_ACL
Expand Down

0 comments on commit a3ac973

Please sign in to comment.