From patchwork Fri Jun 30 17:48:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13298586 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 D9FF5EB64DC for ; Fri, 30 Jun 2023 17:49:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 751A38E0040; Fri, 30 Jun 2023 13:49:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7020E8E000F; Fri, 30 Jun 2023 13:49:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A2EC8E0040; Fri, 30 Jun 2023 13:49:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 49C4F8E000F for ; Fri, 30 Jun 2023 13:49:02 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F196C160DE9 for ; Fri, 30 Jun 2023 17:49:01 +0000 (UTC) X-FDA: 80960150082.12.BDBE096 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 2D28A180019 for ; Fri, 30 Jun 2023 17:48:58 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HIDO8gao; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.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=1688147339; 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=MQpGR3KsSrD2meRTxWtenFFXrfSzuXHiLNi59Pfwy8o=; b=qYDyTpYeVX5CjQjY4FCedtkxlKLvlFxMBLrTiW+92abZScwcq6gCkfg8ex1yxzxfDlzApp vzRApiF7CfEHwPycRdvZnVQ9mW3LuIhGXxGWhpfgywyvz7hhDwKV6V2k55tQTbbU+lgcEY 0kHOj+Eq930KOkYU/qsWViksjH1SP3Y= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HIDO8gao; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.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=1688147339; a=rsa-sha256; cv=none; b=Kc9tT4R96MWaZAi+/c/WexagViE2Qm8VbPeqw88Uq7NQC3TxEEEjrg/Sp4vgS3yxSlc4XD hbslv7LfxtMJzlWmP8sT3U7ZEims9Md8hOxrp8ZN/xF9VEK1BvFHspBPmnEQjA140KMYow 2B73c4zyuY2YOaH4ZLHCAs4TTjwbHq0= 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 4C93E617E1; Fri, 30 Jun 2023 17:48:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BBCEC433CB; Fri, 30 Jun 2023 17:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688147338; bh=lpcIrpUUhkkDjNh21WLxKZUWboCaHEQE1ZuJQA6VvY4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HIDO8gaorTxtlC6gS6AuM6QEXfPdbdEGL9QKN8puDoapE+HKJ9F/8+wmmTOPRCF7g PD5NHZsNRlwIg6h+JcRcEKJQ4+os8WDGbfvzi+ONC5Ood2iZQirG/WYny7xIQQs//I EQvmziJ3NjiMrJTt2q0v4ivFJ68fD6ypLe/Ik3u0S5KwZS9HutdestcxAuy3kWboQx MTq61sIYA9MOAzIsVEovyHP/ouimAbkEpfYvnr1NWwCV0+qmZQ+ol8TVCtIFcR43tG 6Fh4I9SYxJTrYkQkDbxbuDoflZ3kJV/Prljn8cWuag6T5sZjdAuMltbB4APsADiJSE sbEl0DxiHkNgA== Subject: [PATCH v7 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: Fri, 30 Jun 2023 13:48:56 -0400 Message-ID: <168814733654.530310.9958360833543413152.stgit@manet.1015granger.net> In-Reply-To: <168814723481.530310.17776748558242063239.stgit@manet.1015granger.net> References: <168814723481.530310.17776748558242063239.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 2D28A180019 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: tdrqoreg74mbbd5t1m65kdmjnp489bnp X-HE-Tag: 1688147338-180262 X-HE-Meta: U2FsdGVkX18GsNSHuy4wVbnZ6ASAS+Vnege0H88D/SQqKZtbNTWTfB5WKNNJF7k0EoKIkphyCvsL6P51AsMDwFaw0yP/cHgOJfDg6moUmdAWNgHchVjg4ijqctbga551iRzWxXC1sOE0L6C8BcYD5RAJvYPcjFoNZN0ReBtkP9ihasd90aIIMb66TlLup9cd61AI2WMZQkNk2QM/ESpgPrS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kCJofv9K0WyCeO6UwjqdHk57kDAYIzkG+X+pT/D6w9gbKzK7DarKeVEatj5YsA6VTH6tGYugog== 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 2f2e0e618072..ba3d7db90c9d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3293,26 +3293,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); @@ -3327,6 +3323,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)