From patchwork Mon Jun 26 18:21:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13293331 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 A2835EB64D7 for ; Mon, 26 Jun 2023 18:21:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41EDD8D0005; Mon, 26 Jun 2023 14:21:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CDC68D0001; Mon, 26 Jun 2023 14:21:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BD008D0005; Mon, 26 Jun 2023 14:21:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 200D08D0001 for ; Mon, 26 Jun 2023 14:21:39 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E3CF7AFE00 for ; Mon, 26 Jun 2023 18:21:38 +0000 (UTC) X-FDA: 80945717076.05.8E5C148 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 1808F140005 for ; Mon, 26 Jun 2023 18:21:36 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=K7YmwTKS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687803697; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HyWy4W98NhZTL9TWC2BPjccfVvBbQZVYnwl3nGeECrM=; b=6+x2/ZhHTCX/npZNZ6CBeCOKpms7o4VR5P2yU8ZcYmOBSwgtrGbHjqr18aBGrsZVXOlbmt 3J4yPqUJ2iIf651LmLj6rwTEBlnSZFM//Sqfmqy5a05xVDIfnBrEOCbM2Ty8LShAKcAJxR U2BF+vJMwTwuEmAjbfwH8k99uk0dCXU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=K7YmwTKS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687803697; a=rsa-sha256; cv=none; b=pbXNkiIfRdV7dZXOJHMxhqAuiOOWFBg+LWSKvdQRWMB46TptweAp2QxwoYVRjw1hIOEHxQ TeT4DShrFuVvQNDlDoZD+0U7HSlzH5Htq1DfZwNs3AuaITdHFCyV82/5C23XwfDa+hUbBl pxe7M/PGSyOKxcwRllI23tTQHi7VMpg= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 41F9A60F60; Mon, 26 Jun 2023 18:21:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C29DC433C0; Mon, 26 Jun 2023 18:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687803695; bh=u0otBwYFQ+z8N18f7DVMp5oxjO//N2A60QgEjFLrBOg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=K7YmwTKSw768CNYcRStL5txsH8CmrKRhhVEgaVydmn577NY68l7sa7ZqGCeba8x1K jK8Xi9twCgjTsJhIOjZZYxPeIco8yb1wi4AsJacykLSYrYgybBsQ5qAvhEXv7O/0He ur4xSS5keX1wVFe0kxAtpqKm6f8MpnXMn4gW2dzJ15KaVw2BFcfAwelrNs55FvPz9T DrtebEguX4tH6NqXyQo6pLDjkhnJyxW3dCuAUsYHPw7cDwbXzMYqpBJm4NRCVqkonw RB+/x79n6VzegdWx1s/zxO/we5BDMvX68EJ24qiNPTV+x7dIM6k2b+3dBUEqDHjs6/ E0rTLSNzFEGTg== Subject: [PATCH v4 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 , jlayton@redhat.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Mon, 26 Jun 2023 14:21:34 -0400 Message-ID: <168780369414.2142.7968970882438871429.stgit@manet.1015granger.net> In-Reply-To: <168780354647.2142.537463116658872680.stgit@manet.1015granger.net> References: <168780354647.2142.537463116658872680.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1808F140005 X-Stat-Signature: gmokupka7gx5ny51psgk3d6xhxq7babk X-HE-Tag: 1687803696-249082 X-HE-Meta: U2FsdGVkX197GuFhpM6pa9/7u3g0pHYwX9gP+0B7UKwgoncmpeGm+Hp/8CiSwDjX4Q0me7Boqb+lXazS/ACjpMQgF7hh0+gVZe2MGrAeFKRMdUlceRMU2M06pXCQkBZZHx2mlc9xYG8D7SE1Uqq17ELi49EvlC/h+iKD3PNey9EFaywrVh7I5bZhadv0cPkgB6vhWKUTNjw/x1+0+VMsEe1Hjl7vv9+CKvGU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03o99z6g2lbh/pL8oXleQfAhR4Z5cfTQUiD6ZIzRIHdqMrbTn6WJAOm2+WwLck2ja+A== 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 Reviewed-by: Christoph Hellwig --- 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)