From patchwork Tue Jun 6 13:11:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13269195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFE9EC77B73 for ; Tue, 6 Jun 2023 13:12:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238135AbjFFNMD (ORCPT ); Tue, 6 Jun 2023 09:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238128AbjFFNLT (ORCPT ); Tue, 6 Jun 2023 09:11:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DABA171D for ; Tue, 6 Jun 2023 06:11:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 054F2632EF for ; Tue, 6 Jun 2023 13:11:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49B5C433D2; Tue, 6 Jun 2023 13:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686057067; bh=u0otBwYFQ+z8N18f7DVMp5oxjO//N2A60QgEjFLrBOg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=JbNBABKontbCwxlBmCbgb53L+r3ClkUEcy/pix2iQTSQrm4wG0Ut5O1PNkwtl/tkc fcVFp/o2WMTQP1ukmGZxhhxK0epu/Hb5wf6/JQd9t2rMQ8ZKMYKaK8fGEWUvzFxtg+ Zsm+3AGV/OYNDLgLKJtruy6LStpYQ/+zv4P9NleyF23jYlRhZC/o94eeTRa72HKykE HL6eHLij77ycF7f14I8ayfRA0iy6qx7ZBtKlPyj0FDh1pIDuLAq9GmFVYkbAtKHuv2 LlrC2bOkKURujeISHZ/950XiuAcydS7J8tsWR1ks2rCYFMFRO85xXE3rJa+N9EBlIn i5gy1CWDQ8PuA== Subject: [PATCH v3 2/3] shmem: Refactor shmem_symlink() From: Chuck Lever To: viro@zeniv.linux.org.uk, brauner@kernel.org, hughd@google.com, akpm@linux-foundation.org Cc: Jeff Layton , Chuck Lever , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Tue, 06 Jun 2023 09:11:05 -0400 Message-ID: <168605706595.32244.17121016307596271925.stgit@manet.1015granger.net> In-Reply-To: <168605676256.32244.6158641147817585524.stgit@manet.1015granger.net> References: <168605676256.32244.6158641147817585524.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Chuck Lever De-duplicate the error handling paths. No change in behavior is expected. Suggested-by: Jeff Layton Signed-off-by: Chuck Lever --- mm/shmem.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index e40a08c5c6d7..721f9fd064aa 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3161,26 +3161,22 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, error = security_inode_init_security(inode, dir, &dentry->d_name, shmem_initxattrs, NULL); - if (error && error != -EOPNOTSUPP) { - iput(inode); - return error; - } + if (error && error != -EOPNOTSUPP) + goto out_iput; inode->i_size = len-1; if (len <= SHORT_SYMLINK_LEN) { inode->i_link = kmemdup(symname, len, GFP_KERNEL); if (!inode->i_link) { - iput(inode); - return -ENOMEM; + error = -ENOMEM; + goto out_iput; } inode->i_op = &shmem_short_symlink_operations; } else { inode_nohighmem(inode); error = shmem_get_folio(inode, 0, &folio, SGP_WRITE); - if (error) { - iput(inode); - return error; - } + if (error) + goto out_iput; inode->i_mapping->a_ops = &shmem_aops; inode->i_op = &shmem_symlink_inode_operations; memcpy(folio_address(folio), symname, len); @@ -3195,6 +3191,9 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, d_instantiate(dentry, inode); dget(dentry); return 0; +out_iput: + iput(inode); + return error; } static void shmem_put_link(void *arg)