Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755035Ab2EUPbu (ORCPT ); Mon, 21 May 2012 11:31:50 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:65374 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754462Ab2EUPan (ORCPT ); Mon, 21 May 2012 11:30:43 -0400 From: Miklos Szeredi To: viro@ZenIV.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, hch@infradead.org, torvalds@linux-foundation.org, mszeredi@suse.cz Subject: [PATCH 14/16] vfs: nameidata_to_filp(): don't throw away file on error Date: Mon, 21 May 2012 17:30:18 +0200 Message-Id: <1337614220-6174-15-git-send-email-miklos@szeredi.hu> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1337614220-6174-1-git-send-email-miklos@szeredi.hu> References: <1337614220-6174-1-git-send-email-miklos@szeredi.hu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1454 Lines: 53 From: Miklos Szeredi If open fails, don't put the file. This allows it to be reused if open needs to be retried. Signed-off-by: Miklos Szeredi --- fs/open.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/open.c b/fs/open.c index 161c15f..0510e58 100644 --- a/fs/open.c +++ b/fs/open.c @@ -814,10 +814,11 @@ struct file *nameidata_to_filp(struct nameidata *nd) /* Pick up the filp from the open intent */ filp = nd->intent.open.file; - nd->intent.open.file = NULL; /* Has the filesystem initialised the file for us? */ - if (filp->f_path.dentry == NULL) { + if (filp->f_path.dentry != NULL) { + nd->intent.open.file = NULL; + } else { struct file *res; path_get(&nd->path); @@ -826,6 +827,7 @@ struct file *nameidata_to_filp(struct nameidata *nd) if (!IS_ERR(res)) { int error; + nd->intent.open.file = NULL; BUG_ON(res != filp); error = open_check_o_direct(filp); @@ -834,7 +836,7 @@ struct file *nameidata_to_filp(struct nameidata *nd) filp = ERR_PTR(error); } } else { - put_filp(filp); + /* Allow nd->intent.open.file to be recycled */ filp = res; } } -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/