From patchwork Fri May 5 18:38:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13232958 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82AC0C77B7C for ; Fri, 5 May 2023 18:38:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 211216B0096; Fri, 5 May 2023 14:38:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C1756B0098; Fri, 5 May 2023 14:38:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D7446B0099; Fri, 5 May 2023 14:38:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by kanga.kvack.org (Postfix) with ESMTP id EE48B6B0096 for ; Fri, 5 May 2023 14:38:26 -0400 (EDT) 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 AADE860BCB; Fri, 5 May 2023 18:38:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8C9BC433EF; Fri, 5 May 2023 18:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683311906; bh=u0otBwYFQ+z8N18f7DVMp5oxjO//N2A60QgEjFLrBOg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=gPlOSuRGuKYxTGimCwFLk9f2RDwOmaaeCwKD4tbcFOJdiG3o5fyxtfFeuFzra8nJ9 NOL4KzIYcDdubbdjqTKKNGAZl1cSxCQZSYhY63UkHXOMc4Kbd4rBvlDn+WBB+zaCKC 7NzP6ja3qOzfy54q8WksTMrLNU5pMez5JPOiU6ngoruX5qeSxQj5Qk4nFzxAYhBlBw imxIDFCmO0svxoaqfTmCcA7ZiP6uqr61KnhKXhqvm/JVcSZhktJQI4AfVmKMJ+c0JH S5z0fd0Zsqya0OVar4fm2n5tv/5FmxEYamrrg717xG4IocBr+1Rf8oXUndl8/BpNal RXFmupFPNK6IA== Subject: [PATCH v2 1/5] shmem: Refactor shmem_symlink() From: Chuck Lever To: hughd@google.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Fri, 05 May 2023 14:38:14 -0400 Message-ID: <168331188458.20728.11056177116501982469.stgit@oracle-102.nfsv4bat.org> In-Reply-To: <168331111400.20728.2327812215536431362.stgit@oracle-102.nfsv4bat.org> References: <168331111400.20728.2327812215536431362.stgit@oracle-102.nfsv4bat.org> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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)