Received: by 2002:ac0:adb4:0:0:0:0:0 with SMTP id o49-v6csp6451imb; Tue, 10 Jul 2018 19:28:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcLq39xPl6Toj+RskE8UPs8luNHchoKzrf7k6mrGLPK8Ho3Jnnjru6C5pQzewUIOB5VhpON X-Received: by 2002:a17:902:9a06:: with SMTP id v6-v6mr26859456plp.21.1531276094949; Tue, 10 Jul 2018 19:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531276094; cv=none; d=google.com; s=arc-20160816; b=gr8GG5mVqLMKh4rXmP3Qu7KZX4qdgCW5ERUBb7MkgvXMO2NCn7UbQxOWDAtd/P2qat KktSRbEwNZ2GY86G6+3EljzN8nzAdS4qiMOLPai7pRRs0o7V+5eu94RZZk8WW6rgdp5b l+Tf0UuantdCqvzJqWhlw2k3hZCvTqUODvQD6HdwFJJvy6Yec4wRqeTqLLzm31vsREwi kJPefKTcTSohKDEcklIL8dJZkMJfBvwlOwqvP39ELS0nHn7eo4d1zq7+GIlRmbhLLC36 5wL7qHziLlcnk+5lCB1coi77i40jSjpHGwRTPAj93AjOZyTHR6lXe4RozHzEoQrkeZKn otQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=VIYcrgY/gSTDW7ICCSFyaB3yug2PMLok3GcDGP1CIDE=; b=haWb44IW0ihseOsV+5L3fUbw9T0KXUHGCrm2MVgjwpIjpfbxqP0vzRbVYUrf9Xy6RX oNlCNdkSVYmJuXtSfGiX6awA05egi+SGQN9tGZ33qbHe4BJoxYZM/SP5HRJPBhGx4bWo 7tVdM7Km+/8wLBnadFg7fQVGPAyGOENYA2me0P1x2IQm+CY0/Bk5woOejrR+pP4tLERj cbUOb39QXFimB0Hy4kS96hp4FTpmCa1/Vulia397srcn75oiko3/sy08xVhcOC9oUvsl mZEi8deGUPLstRZQUCInGKdZBqjRNn/rEWWojPMjm9DvuVZtf7O55orN6TeWAvOY29wB //2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8-v6si16725108pgs.211.2018.07.10.19.27.59; Tue, 10 Jul 2018 19:28:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732466AbeGKCYE (ORCPT + 99 others); Tue, 10 Jul 2018 22:24:04 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45510 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732372AbeGKCYD (ORCPT ); Tue, 10 Jul 2018 22:24:03 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4la-0003Hn-Px; Wed, 11 Jul 2018 02:22:06 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [RFC][PATCH 07/42] create_pipe_files(): use fput() if allocation of the second file fails Date: Wed, 11 Jul 2018 03:21:31 +0100 Message-Id: <20180711022206.12571-7-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180711022206.12571-1-viro@ZenIV.linux.org.uk> References: <20180711021136.GN30522@ZenIV.linux.org.uk> <20180711022206.12571-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro ... just use put_pipe_info() to get the pipe->files down to 1 and let fput()-called pipe_release() do freeing. Signed-off-by: Al Viro --- fs/pipe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index bb0840e234f3..9405e455f5b1 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -771,8 +771,9 @@ int create_pipe_files(struct file **res, int flags) res[0] = alloc_file(&path, FMODE_READ, &pipefifo_fops); if (IS_ERR(res[0])) { - err = PTR_ERR(res[0]); - goto err_file; + put_pipe_info(inode, inode->i_pipe); + fput(f); + return PTR_ERR(res[0]); } path_get(&path); @@ -781,8 +782,6 @@ int create_pipe_files(struct file **res, int flags) res[1] = f; return 0; -err_file: - put_filp(f); err_dentry: free_pipe_info(inode->i_pipe); path_put(&path); -- 2.11.0