From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA755C4338F for ; Wed, 25 Aug 2021 06:51:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEE7960F58 for ; Wed, 25 Aug 2021 06:51:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239076AbhHYGwE (ORCPT ); Wed, 25 Aug 2021 02:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238276AbhHYGwC (ORCPT ); Wed, 25 Aug 2021 02:52:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB6BC061757; Tue, 24 Aug 2021 23:51:17 -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=Xgcc93fALZjStOpXyGyFVuh26GCmgHjM5rA7NYirgHw=; b=AmXpTJ8f0x6phT2OIDmygUmAND /HAimYCbZwTFWCkVQCjSPdsqPaExkCmnSvVWl6bqrblQS0sUJyk+hDOg1XWSoUPVQykcIVIQx9pSp g43kcRxN/FGBsJQ7CfsSD2mJnK/CKSTvST7P5ISsWHQYpJLDJKJzSkL6ymtbhCHoqazwm7pArcPWe 7f0rkZvrZppDoNLfTYlAkiUtdLBRsN8DrdnzOlMh7tXcazSETnjksQF+EhG1TGJHzywqDbt2yjr6Q ut6if0mDeMrDerSTNgoBWq45TjGTfApoyvAt2G98psUIuSZaXzz+sqHLtrWjTcmWPtSa+IJpa0leG JTct9eSA==; Received: from [2001:4bb8:193:fd10:ce54:74a1:df3f:e6a9] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mImjN-00Bzaq-Om; Wed, 25 Aug 2021 06:50:08 +0000 From: Christoph Hellwig To: Joel Becker Cc: Sishuai Gong , Al Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 1/4] configfs: return -ENAMETOOLONG earlier in configfs_lookup Date: Wed, 25 Aug 2021 08:49:03 +0200 Message-Id: <20210825064906.1694233-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210825064906.1694233-1-hch@lst.de> References: <20210825064906.1694233-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just like most other file systems: get the simple checks out of the way first. Signed-off-by: Christoph Hellwig --- fs/configfs/dir.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index ac5e0c0e9181..cf08bbde55f3 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -456,6 +456,9 @@ static struct dentry * configfs_lookup(struct inode *dir, int found = 0; int err; + if (dentry->d_name.len > NAME_MAX) + return ERR_PTR(-ENAMETOOLONG); + /* * Fake invisibility if dir belongs to a group/default groups hierarchy * being attached @@ -486,8 +489,6 @@ static struct dentry * configfs_lookup(struct inode *dir, * If it doesn't exist and it isn't a NOT_PINNED item, * it must be negative. */ - if (dentry->d_name.len > NAME_MAX) - return ERR_PTR(-ENAMETOOLONG); d_add(dentry, NULL); return NULL; } -- 2.30.2