Messages in this thread | | | Date | Sun, 8 Jan 2017 01:55:11 -0800 | From | Christoph Hellwig <> | Subject | Re: [PATCH v4 1/3] xattr: add simple initxattrs function |
| |
> +/* > + * Callback for security_inode_init_security() for acquiring xattrs. > + */ > +int simple_xattr_initxattrs(struct inode *inode, > + const struct xattr *xattr_array, > + void *fs_info) > +{ > + struct simple_xattrs *xattrs; > + const struct xattr *xattr; > + struct simple_xattr *new_xattr; > + size_t len; > + > + if (!fs_info) > + return -ENOMEM;
This probablt should be an EINVAL, and also a WARN_ON_ONCE.
> + xattrs = (struct simple_xattrs *) fs_info;
No need for the cast. In fact we should probably just declarate it as struct simple_xattrs *xattrs in the protoype and thus be type safe.
> + > + for (xattr = xattr_array; xattr->name != NULL; xattr++) { > + new_xattr = simple_xattr_alloc(xattr->value, xattr->value_len); > + if (!new_xattr) > + return -ENOMEM;
We'll need to unwind the previous allocations here.
| |