From mboxrd@z Thu Jan 1 00:00:00 1970 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 A7B49C43334 for ; Wed, 20 Jul 2022 09:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237778AbiGTJXa (ORCPT ); Wed, 20 Jul 2022 05:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbiGTJX2 (ORCPT ); Wed, 20 Jul 2022 05:23:28 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3441D474E2 for ; Wed, 20 Jul 2022 02:23:27 -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=1658309005; 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=P7Isxxvpi8y4H75QfyaFmD1XqHHtW8I94j4NGpiu0Yh1q3dHxuV0vRu//ER6SzzuMthtkS 2aCWimK4FVKWl0aK19Zc8+FIcnP0+8+J4xFoTbJ4ISSGIHMDDjzWUN9BpQDSEuackH6y5W FO3/lnLw9c3VB8Q4k/z8oKLqYJ3ZZtE= 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:47 +0000 Message-Id: <20220720092259.3491733-2-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 Content-Transfer-Encoding: 8bit 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); -- 2.37.0.170.g444d1eabd0-goog