From patchwork Tue Jun 27 20:53:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13295027 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 5826BEB64D9 for ; Tue, 27 Jun 2023 20:53:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE71A8D0005; Tue, 27 Jun 2023 16:53:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E704E8D0001; Tue, 27 Jun 2023 16:53:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEA778D0005; Tue, 27 Jun 2023 16:53:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BAB848D0001 for ; Tue, 27 Jun 2023 16:53:20 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 82E6A40A17 for ; Tue, 27 Jun 2023 20:53:20 +0000 (UTC) X-FDA: 80949728160.12.2BA57F3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id A5B5940007 for ; Tue, 27 Jun 2023 20:53:18 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="ZQx/UsZy"; spf=pass (imf12.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687899198; 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=w7U1ETJF3+b23Qu0/lBzi5jnA7O+fNb1OvT4FhatSZs=; b=tcAm65LxWSUZ/J8oEJSWiccN1QsZehbG30CJq2nw0yZ9UDyZJdW/B5aIrXxkb2cIsPsn3p zKlZZGBocPK1H95ZQXUMF/A3XdfAZbcUzLDdR6p0yTfn8+g1b7oynd1eJxGvzh0Y30h7ce 7eFFJ56x99rPFSzQKZMpaN0QQEdmWN4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="ZQx/UsZy"; spf=pass (imf12.hostedemail.com: domain of cel@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cel@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687899198; a=rsa-sha256; cv=none; b=c/8PTQu3c6/xmbc+5mGFP2l5yIj81cvveOooJ6SgZw6GgylPa8hvhmzArwI5gDhzXNZ4fo hy7UsrpRf0HQ7Sn/PIl0V5Ru+s3jfAVnjWODuppjoPh4vLj9zujM9Nj2HZX9FLyIZ/81n+ gYgS98rE1NTtm+WixnPiyOMm6OS0Twg= 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 D3F166121B; Tue, 27 Jun 2023 20:53:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 956B7C433C8; Tue, 27 Jun 2023 20:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687899197; bh=e4I/gNHDIjpSKufk2xxM8B41vPKw1FE7ZKuVtO31ayU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ZQx/UsZypzNmJsOCaPFJvsSA0E291nghrjaD7ve+fzrq+xkHa/7XJDDqfcKkSYv2Q eAe3J7BAwoTKcVVd8JYKBImzZC32NK0j36dAN1Ho94daTL6oubGB405E++oI5toTvk 8VKGxUiMbXSUCs1qhvoGFqulorX+BB2Z1QUXXgSusNJlDp2SUzj3HjlSjwEp2oTLuB y2WJuNFgVwRtS1KrvnDVptZWnPytWz6kGBx+Zx1BRI6T71oyatywrVOj3sI32gqpIb GNkTTDOEUKmOHSX1X+x33gZDbWncW0mxsOG1nxypWOBkvIC/TS5c9ahPNQ2qvyAFCg t6ScQt8hZF0Og== Subject: [PATCH v5 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 , Christoph Hellwig , Chuck Lever , jlayton@redhat.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Date: Tue, 27 Jun 2023 16:53:15 -0400 Message-ID: <168789919571.157531.3616549508867843146.stgit@manet.1015granger.net> In-Reply-To: <168789864000.157531.11122232592994999253.stgit@manet.1015granger.net> References: <168789864000.157531.11122232592994999253.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: A5B5940007 X-Rspam-User: X-Stat-Signature: yh5xccpounjghb8zse94eopghegxaz3a X-Rspamd-Server: rspam01 X-HE-Tag: 1687899198-286352 X-HE-Meta: U2FsdGVkX1++ZWa45AYDUIvGTTwkZiuC7vLtmHWjxGC37au+fbYTFCg93O8fVjEODKbnLccKzNMdx0NOXU/TqCTNz3jHRxNoSvomeCrk7VAaOSQLl7YJGaosDom8oAhVJT4vq8nVK9ESF8JyOOaoK4rBFUBAjsWrsQQU0uKOrbqsEIsFtfNZDJAOk1NFba1LOSoccr2eiZlqryhL1UU/+Xjb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TkTqOjEIPxGYa5uqN5DvwXvSUsQNKNi4+NGNyGX6QnN7+jzIyyZqTt3XjNQ0roGwgd2tncZJg== 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 Reviewed-by: Christoph Hellwig 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)