Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1906035imm; Sun, 8 Jul 2018 14:09:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5kwn4xMSE35OdPp5jYxAwSo4mR3kCDXjqHTme11kbq20V1QqFANpsAqSoc3xmUstHl2Rf X-Received: by 2002:a63:ec14:: with SMTP id j20-v6mr16316376pgh.28.1531084152840; Sun, 08 Jul 2018 14:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531084152; cv=none; d=google.com; s=arc-20160816; b=LWac7IVWSXi7g5Rhx2C33+jeTvZC0FxLb1cjrxys6vFWMG4ZORFOnGJ72/lfVakkW5 Ap9j0qY/P70vkB0zf9geSbY+Zo6RnAvSg/mM8CsXdanL0k0alA0cjXsID20yj0kTLIJj AjF/NCEBiz2T0XRacKYJEz38m2kqeBwv1huouLFe4rcnt5hECZvbVzuBISJSP8tHBMYT R5qt5T5nP1y/Yt5+NSsdRFJoUiPVFesYl7XHE1QXm5wbIb5o9Br6gSH3YxBrNAJIKhuY th5K/rvKJj2DKC9S0gyYfkLz7wk/mZp8/ptdHYaipWcfHO0TJ0QMUizrUspTR/wAQ+RO 8cww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=+r7gEYt/YDpzuanpxY4yUcIFWJT4rVS3DBsdnW4JdZY=; b=R+pyb6HoznHZVTIclR/qa+Q4Rag8e4FMQ7nWm1fRXi/xXvUALCexdk7uCkc/sRG+Y4 uT/qW5HErYri7qykW1ltr/MVwSmlc5OvmDMNcwF0YNWFlJpge713F7LFOjpr855jkU3q 1nFm3FxLTJk9pCQQ3STKChaDZz28EG+dwHz4tJ5Ms/LZXYn235efUikZb0T0axkLaNQW TDnj2gaXPqgLHZ6LFkK/OS+uWAP5SYF6Yr2KfT+7aVImIkL3gALwaZNMtRUks4dqwyyk 8HGRuz+05EQ//QpeJBAfnLL8vo9T1sBVUv+glFJDEt/VSkzZeRnwY+UXBc/dAwyPgtW3 6mrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hF90lB6a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 43-v6si13329345pla.362.2018.07.08.14.08.58; Sun, 08 Jul 2018 14:09:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hF90lB6a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933475AbeGHVFt (ORCPT + 99 others); Sun, 8 Jul 2018 17:05:49 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:45471 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933401AbeGHVFp (ORCPT ); Sun, 8 Jul 2018 17:05:45 -0400 Received: by mail-pf0-f196.google.com with SMTP id i26-v6so719201pfo.12; Sun, 08 Jul 2018 14:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+r7gEYt/YDpzuanpxY4yUcIFWJT4rVS3DBsdnW4JdZY=; b=hF90lB6aFF1E1s2xLi195Y0RxLyhk0PGmFl0fg3t1nyb+aH0VgtNuYEt6r3F7TNeh5 L7zWMldchbFEW9xVuWJetgoZpRtp+QHOKXMXZjas4kGD2+YaQpIOgPAJtmv/mF5H4iTN 5DZVzw4CCzrK7QPiULPgqMHE6OUWIoETsA4LrXyi+Ix1uC9tLxRHLvigrTfUlvZc9j/r m1LW4EViQhUE23i1YFD1Q8yn6JZsKlJ/UTBL3fj4/2CcrH9Ve/dXSr4CarVzOMDItxgy z+bgiDC8C28zwPfIB+8EcYoIpyp6CJRI5LGqRzppWL2Zssx52oagq+i/OY6ttwSnaTNB KUIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+r7gEYt/YDpzuanpxY4yUcIFWJT4rVS3DBsdnW4JdZY=; b=RKC7MZKaPEq2OarkAIIhGndXvMfSbpSATvYnkke6TlAqIY6hEOFQp9y92wt2XjN5sJ GLjcBcL8J6VwHUpeu50vOrwqXPojGRy1koswavPgAC2fBUbEcXBYZJnVlKKFmhZHmRNC 7l8r15vDBANUvx9Iw82FR6GLG7hdtnFmHkAFlrOknTiPh3xSicasoZohYB82O6Ugu1cX WefSWIYV2Bm8bUxqx0plafOwAIr63sQ58bcb2q71ezNYDCHiD8/BqI0sg6jLiaFFasAu kZjBOjtLghKqIwdv1n5Ki5opz/UB0chNryIksHrs/10CubSdP4JsRrPQWOCoYtpCUc1v FT4A== X-Gm-Message-State: APt69E2WFeuEqaorebpeOvNDHGYtYLBkuuedBhKGocpkPLjv+uZTigq0 wT0J5RfwXbHULQkce0cH8po= X-Received: by 2002:a62:675b:: with SMTP id b88-v6mr18948003pfc.24.1531083944446; Sun, 08 Jul 2018 14:05:44 -0700 (PDT) Received: from sol.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id x68-v6sm23355681pfb.138.2018.07.08.14.05.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jul 2018 14:05:43 -0700 (PDT) From: Eric Biggers To: David Howells , Alexander Viro , linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Eric Biggers Subject: [PATCH 14/18] fsopen,fspick: factor out log allocation Date: Sun, 8 Jul 2018 14:01:50 -0700 Message-Id: <20180708210154.10423-15-ebiggers3@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180708210154.10423-1-ebiggers3@gmail.com> References: <20180708210154.10423-1-ebiggers3@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers Signed-off-by: Eric Biggers --- fs/fsopen.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/fs/fsopen.c b/fs/fsopen.c index b3a22848f8eec..02edb4705fac2 100644 --- a/fs/fsopen.c +++ b/fs/fsopen.c @@ -223,6 +223,16 @@ static int fsopen_create_fd(struct fs_context *fc, unsigned int o_flags) return fd; } +static int fscontext_alloc_log(struct fs_context *fc) +{ + fc->log = kzalloc(sizeof(*fc->log), GFP_KERNEL); + if (!fc->log) + return -ENOMEM; + refcount_set(&fc->log->usage, 1); + fc->log->owner = fc->fs_type->owner; + return 0; +} + /* * Open a filesystem by name so that it can be configured for mounting. * @@ -257,14 +267,12 @@ SYSCALL_DEFINE2(fsopen, const char __user *, _fs_name, unsigned int, flags) if (IS_ERR(fc)) return PTR_ERR(fc); - ret = -ENOMEM; - fc->log = kzalloc(sizeof(*fc->log), GFP_KERNEL); - if (!fc->log) + fc->phase = FS_CONTEXT_CREATE_PARAMS; + + ret = fscontext_alloc_log(fc); + if (ret < 0) goto err_fc; - refcount_set(&fc->log->usage, 1); - fc->log->owner = fs_type->owner; - fc->phase = FS_CONTEXT_CREATE_PARAMS; return fsopen_create_fd(fc, flags & FSOPEN_CLOEXEC ? O_CLOEXEC : 0); err_fc: @@ -315,12 +323,9 @@ SYSCALL_DEFINE3(fspick, int, dfd, const char __user *, path, unsigned int, flags fc->phase = FS_CONTEXT_RECONF_PARAMS; - ret = -ENOMEM; - fc->log = kzalloc(sizeof(*fc->log), GFP_KERNEL); - if (!fc->log) + ret = fscontext_alloc_log(fc); + if (ret < 0) goto err_fc; - refcount_set(&fc->log->usage, 1); - fc->log->owner = fc->fs_type->owner; path_put(&target); return fsopen_create_fd(fc, flags & FSPICK_CLOEXEC ? O_CLOEXEC : 0); -- 2.18.0