From patchwork Wed Jun 28 15:25: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: 13295922 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 AB582EB64D7 for ; Wed, 28 Jun 2023 15:25:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BCD78D0005; Wed, 28 Jun 2023 11:25:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46D288D0001; Wed, 28 Jun 2023 11:25:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35BC38D0005; Wed, 28 Jun 2023 11:25:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 295558D0001 for ; Wed, 28 Jun 2023 11:25:22 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EA46C80B17 for ; Wed, 28 Jun 2023 15:25:21 +0000 (UTC) X-FDA: 80952530442.20.922D342 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id D43F3180022 for ; Wed, 28 Jun 2023 15:25:18 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j0i6ikly; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.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=1687965918; 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=KL7ja1kFguXsfZfW0FAvLFbJ0oqWlPGIBkpWUkLCSLj4kpnZvjpxJ2f23zHkr8EcREdRQk o24y67hBwVr6eIGhMCDr74V2LcUeIBoRt+N6U00isTQOzQSkiSlH2DZhmrHkBsa6iS8C30 EHCFMe3g++kIbUJSNGQsDYZFLUcO4OA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j0i6ikly; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.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=1687965918; a=rsa-sha256; cv=none; b=1Jb63Il6+MHfpmnyWhYzS1zlrOueiyfAH/SBn4G6esLbLNRQ2KotyEhcmKBNpK++E/9LXl zfGlFVT1t7SSdgit5vqPAhvuE226yZIIJvWY9/o8SJiVL6vJDqkHXS4Vr2w/qOMG4GMC8a YdeQ7CH3obicrF1IHgVybsnjw/LU5AU= 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 E782161368; Wed, 28 Jun 2023 15:25:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4E3AC433C9; Wed, 28 Jun 2023 15:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687965917; bh=e4I/gNHDIjpSKufk2xxM8B41vPKw1FE7ZKuVtO31ayU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=j0i6ikly/vKfjVuwx9wICD5KcaOQQ01VEGi3ol8P4+JUzBYb+bgUI0oGPnxlbHbrd iHzrPbCdSvNvOnfpVYD5iZkuYXU47+RI0/ZYrjyQvHnleHON3qExf5wjKf1HiOtQ+K ES+mAU1eJ8piaIb7lSu7XFLKB1p6kSgDB5THy8oE1MBCWD52xhXBHFArJHok4erBr4 Sl83t67t1GjeXvTP2DvXpet4h/9OMSiBM8M1EKm7klMeVYtTu0/O/9RF8/ArL8F1lU pR6yLbhjZ7/qtA42xeNFwUd14F9l5IIvTomiUdF/7NdFiaB7aANHaY1OPpMvxjoSUC 2bZehSg3sC1Kg== Subject: [PATCH v6 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: Wed, 28 Jun 2023 11:25:15 -0400 Message-ID: <168796591580.157221.7871489061567042327.stgit@manet.1015granger.net> In-Reply-To: <168796579723.157221.1988816921257656153.stgit@manet.1015granger.net> References: <168796579723.157221.1988816921257656153.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: D43F3180022 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: udxokaqd8pi4swd8d4nam3sa7k7ob5kb X-HE-Tag: 1687965918-376074 X-HE-Meta: U2FsdGVkX1+KH+SJSjJ1Lj2yH3i9/bwFewmttQLdsA1R96sVisCLvAtiLBXXi7ZQ2IgKzW1GXDAvcQMBRtIynTV0BuG4G7QCvq6t7MFdYC9hTdgtheM0/JyLdl0Pr9w7cb6TCIGYPElwAF3h4q4xJ0GouNJJq7k1esIDpV5V9frq9a9RH/HNMhVnAKNwoHHm0VMV1+iExC7rfJ1+UwiiGp/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DK13Yq+kRbLT6c0SZpjLrII9ydoylr6JIb5B0hUBNSWKByw06AgikZcdoBq/Aw== 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)