From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753592AbdBKLFm (ORCPT ); Sat, 11 Feb 2017 06:05:42 -0500 Received: from mx02-sz.bfs.de ([194.94.69.103]:64183 "EHLO mx02-sz.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752936AbdBKLFk (ORCPT ); Sat, 11 Feb 2017 06:05:40 -0500 Message-ID: <589EF000.7050808@bfs.de> Date: Sat, 11 Feb 2017 12:05:36 +0100 From: walter harms Reply-To: wharms@bfs.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 MIME-Version: 1.0 To: Christophe JAILLET CC: miklos@szeredi.hu, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] ovl: Avoid some memory allocation References: <20170210211814.18257-1-christophe.jaillet@wanadoo.fr> In-Reply-To: <20170210211814.18257-1-christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 10.02.2017 22:18, schrieb Christophe JAILLET: > Reorder code to avoid allocating and then freeing some memory in an error > handling path. > > Signed-off-by: Christophe JAILLET > --- > fs/overlayfs/namei.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c > index 023bb0b03352..ba80ebb8a104 100644 > --- a/fs/overlayfs/namei.c > +++ b/fs/overlayfs/namei.c > @@ -35,13 +35,13 @@ static int ovl_check_redirect(struct dentry *dentry, struct ovl_lookup_data *d, > return 0; > goto fail; > } > + if (res == 0) > + goto invalid; > + perhaps: if (res == -ENODATA || res == -EOPNOTSUPP) return 0; if (ret < 0) goto fail; if (ret == 0) goto invalid; I think its better to read, i guess the author also as we can find this pattern after the other vfs_getxattr() also. re, wh > buf = kzalloc(prelen + res + strlen(post) + 1, GFP_TEMPORARY); > if (!buf) > return -ENOMEM; > > - if (res == 0) > - goto invalid; > - > res = vfs_getxattr(dentry, OVL_XATTR_REDIRECT, buf, res); > if (res < 0) > goto fail;