Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1243353ybt; Tue, 7 Jul 2020 10:49:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz39OgT4cLDbYWtXOqOO/imnwuwDHaelqIyJVuMpwTOxG5aw98JHgvWlj9vTfnni25Ucbmp X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr47291292edb.191.1594144190361; Tue, 07 Jul 2020 10:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594144190; cv=none; d=google.com; s=arc-20160816; b=R252QDVkOk0UH4JgiG6WL+NG1GCuYExy9ChhdWlPjft24nTLflf7IZZLjIVisHsZke h+57MWX5lYNZYJkkgKZ2yhgUhB8t5xm7wSN/LA2+oc8GmNWakaNOYmehCKC0jxIzz2H+ i+rqeMQ4q30ZzGAzm6+QO2axxnxFFdPuwmtIC87cddsQPUT/5FzxdkDbgq5863j/3qlt 7iAw+WKlziu69YfO37PxiCklvIG0BtC+kJMSKA8XzTmrPhAHFyz8qzQS2TuSfhMZSw+v JdGJQVUHALbFybHPO4luHqzNjJk4g4oyTmZccwh9rrYwbruVsG4Ig4zG+p2acEnBZTMp Ggsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5UdxRZXTOhVUtxH21tqgR494MAXE+7aifhN/sMLl3wo=; b=QZCfMGJU+4C3IDz7Byttq+oDqEBaHvDgWM5umqGGDFU5MHDvsjpfvS6VeGmBUc+ozo dJhgrwfS2dpVUDVrcSgX9s7AzGE+WT4iUkHvbXlCbEEOD1VpZDQRNj+wz5go4Qi7qxV7 kS5ZYcQOjeN1Gc2bXL4IQ/su/BfUAq6qyJpf+1GRaPCaHtH400tQhh0J81YDUbLAPm8Y S36tZY9SdfwfNwN4UGgFI3WbGoIHNWfw2BQbOfA7BUOEOy49clv8mw55Jq+p5JGDpEmR DTRjowvGySAXQnbTkSJbvcXGB7g8UK3aanXTAyFxce9TVHU6aCrA1vUZFdAyiMFbLQ7c OJ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=VnhHfBod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw25si15109768edb.203.2020.07.07.10.49.27; Tue, 07 Jul 2020 10:49:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=VnhHfBod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728751AbgGGRs6 (ORCPT + 99 others); Tue, 7 Jul 2020 13:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728661AbgGGRse (ORCPT ); Tue, 7 Jul 2020 13:48:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A5CC061755; Tue, 7 Jul 2020 10:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5UdxRZXTOhVUtxH21tqgR494MAXE+7aifhN/sMLl3wo=; b=VnhHfBod7FY+/0HQLHZOiY+Dsc waw2TdL0ExD9660hDrFgJc9uRgTQLe07nQZrOQfHpupePKLqoGOLfSakm0VrB8ootaEVdH80w6VwG cIu9Sp985pOpd8JAwDEID1xnj9HoWxyhHmFGgeLJhlYfAVV18za403POJvLs57cXtiv7uGaruDp6m T0rWal21LEl68ttv09A5vHzfn/1yoEjG1f/5UXLO5usD098OtPZK0fTO40EUum9w89s6QjekmS2u1 UCMnffQx4ONN4lXhdhvvCd7Z34aMmEvVWXfbwzSHggxKi8QrGj//dkLlIzTETWEpm4b7p0P0Gpi/y NSY8+y8w==; Received: from [2001:4bb8:18c:3b3b:a49f:8154:a2b7:8b6c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsrhi-0003Kv-IY; Tue, 07 Jul 2020 17:48:27 +0000 From: Christoph Hellwig To: Al Viro , Linus Torvalds , Stephen Rothwell Cc: Luis Chamberlain , Matthew Wilcox , Kees Cook , Iurii Zaikin , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 16/23] proc: remove a level of indentation in proc_get_inode Date: Tue, 7 Jul 2020 19:47:54 +0200 Message-Id: <20200707174801.4162712-17-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200707174801.4162712-1-hch@lst.de> References: <20200707174801.4162712-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just return early on inode allocation failure. Signed-off-by: Christoph Hellwig --- fs/proc/inode.c | 72 +++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 28d6105e908e4c..016b1302cbabc0 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -619,42 +619,44 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) { struct inode *inode = new_inode(sb); - if (inode) { - inode->i_ino = de->low_ino; - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); - PROC_I(inode)->pde = de; - - if (is_empty_pde(de)) { - make_empty_dir_inode(inode); - return inode; - } - if (de->mode) { - inode->i_mode = de->mode; - inode->i_uid = de->uid; - inode->i_gid = de->gid; - } - if (de->size) - inode->i_size = de->size; - if (de->nlink) - set_nlink(inode, de->nlink); - - if (S_ISREG(inode->i_mode)) { - inode->i_op = de->proc_iops; - inode->i_fop = &proc_reg_file_ops; + if (!inode) { + pde_put(de); + return NULL; + } + + inode->i_ino = de->low_ino; + inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); + PROC_I(inode)->pde = de; + if (is_empty_pde(de)) { + make_empty_dir_inode(inode); + return inode; + } + + if (de->mode) { + inode->i_mode = de->mode; + inode->i_uid = de->uid; + inode->i_gid = de->gid; + } + if (de->size) + inode->i_size = de->size; + if (de->nlink) + set_nlink(inode, de->nlink); + + if (S_ISREG(inode->i_mode)) { + inode->i_op = de->proc_iops; + inode->i_fop = &proc_reg_file_ops; #ifdef CONFIG_COMPAT - if (!de->proc_ops->proc_compat_ioctl) { - inode->i_fop = &proc_reg_file_ops_no_compat; - } + if (!de->proc_ops->proc_compat_ioctl) + inode->i_fop = &proc_reg_file_ops_no_compat; #endif - } else if (S_ISDIR(inode->i_mode)) { - inode->i_op = de->proc_iops; - inode->i_fop = de->proc_dir_ops; - } else if (S_ISLNK(inode->i_mode)) { - inode->i_op = de->proc_iops; - inode->i_fop = NULL; - } else - BUG(); - } else - pde_put(de); + } else if (S_ISDIR(inode->i_mode)) { + inode->i_op = de->proc_iops; + inode->i_fop = de->proc_dir_ops; + } else if (S_ISLNK(inode->i_mode)) { + inode->i_op = de->proc_iops; + inode->i_fop = NULL; + } else { + BUG(); + } return inode; } -- 2.26.2