From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938938AbdAHJ4S (ORCPT ); Sun, 8 Jan 2017 04:56:18 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:34160 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755846AbdAHJzN (ORCPT ); Sun, 8 Jan 2017 04:55:13 -0500 Date: Sun, 8 Jan 2017 01:55:11 -0800 From: Christoph Hellwig To: David Graziano Cc: linux-security-module@vger.kernel.org, paul@paul-moore.com, agruenba@redhat.com, hch@infradead.org, linux-mm@kvack.org, sds@tycho.nsa.gov, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/3] xattr: add simple initxattrs function Message-ID: <20170108095511.GB4203@infradead.org> References: <1483653823-22018-1-git-send-email-david.graziano@rockwellcollins.com> <1483653823-22018-2-git-send-email-david.graziano@rockwellcollins.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1483653823-22018-2-git-send-email-david.graziano@rockwellcollins.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +/* > + * 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.