From patchwork Wed Jul 20 09:22:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12923747 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7B89CCA482 for ; Wed, 20 Jul 2022 09:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238300AbiGTJXj (ORCPT ); Wed, 20 Jul 2022 05:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238064AbiGTJXg (ORCPT ); Wed, 20 Jul 2022 05:23:36 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D065447BA1 for ; Wed, 20 Jul 2022 02:23:35 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1658309014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x9H1B0qp5vV2SXCFJBDuseXpKkjoj0nJpiEMWlXy/Qk=; b=WRqXdu5bYrPkFxW0Gvk9tWp5xP/WkwoGkM+snufGlZ0zijt5RPWEtbyWLSk0hV7oA9/Utp KXCxcvnCIdfManuQZQkHCBgMGARefJwRtdDU4yVDUyfjQrWXtWJVi2mHotFJVv9zR4HdJs WZpoD/9TWRF6o9vR3KJNkfJB9gu9J9Y= From: Oliver Upton To: kvm@vger.kernel.org Cc: Paolo Bonzini , Sean Christopherson , Oliver Upton Subject: [PATCH v3 1/6] KVM: Shove vm stats_id init into kvm_create_vm() Date: Wed, 20 Jul 2022 09:22:54 +0000 Message-Id: <20220720092259.3491733-9-oliver.upton@linux.dev> In-Reply-To: <20220720092259.3491733-1-oliver.upton@linux.dev> References: <20220720092259.3491733-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Oliver Upton Initialize stats_id alongside the other struct kvm fields to futureproof against possible initialization order mistakes in KVM. While at it, move the format string to the first line of the call and fix the indentation of the second line. No functional change intended. Signed-off-by: Oliver Upton --- virt/kvm/kvm_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index da263c370d00..cc760ebcd390 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1155,6 +1155,9 @@ static struct kvm *kvm_create_vm(unsigned long type) */ kvm->debugfs_dentry = ERR_PTR(-ENOENT); + snprintf(kvm->stats_id, sizeof(kvm->stats_id), "kvm-%d", + task_pid_nr(current)); + if (init_srcu_struct(&kvm->srcu)) goto out_err_no_srcu; if (init_srcu_struct(&kvm->irq_srcu)) @@ -4902,9 +4905,6 @@ static int kvm_dev_ioctl_create_vm(unsigned long type) if (r < 0) goto put_kvm; - snprintf(kvm->stats_id, sizeof(kvm->stats_id), - "kvm-%d", task_pid_nr(current)); - file = anon_inode_getfile("kvm-vm", &kvm_vm_fops, kvm, O_RDWR); if (IS_ERR(file)) { put_unused_fd(r);