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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47FE7C3ABC9 for ; Tue, 13 May 2025 07:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+gDMbmyzDvj8Y9l0qEdP6uuFgyGYuWQdQZkgqss7oRk=; b=oI8Hpcj1qRtgEhendr34BPjPWf +uJVjCPy//PrjFb5Sp+NTlF4DUAU1uDX6a5DlLxduSxGRALvRNIXNU4qwEjOnHKsvLLJMWqF2mWbH HRraAQW4Hd8BFH589qgTwqCaCBc9eG+enFEi3Efxyugv5DuzDTbWR839MJoLGsn596S6+LsK1TM4y RmtT/VJjkJH9s1Dw+sHZ9PGrSxl93z9HDJzD5BgNgWLHq7v+g3OlmhtLp0yw3aAwW7K6VulV0+bf7 XduuWn8bmQ6aGSv3P91hm0bntB8zQBgQtS6y5fjctMLZcQBpuPKGjQ6TUt4OzHZxFuTs5akOxjgAd xPdlzW4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uEjdD-0000000BZ9R-2kEE; Tue, 13 May 2025 07:00:51 +0000 Received: from 2a02-8389-2341-5b80-3c00-8f88-6e38-56f1.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:3c00:8f88:6e38:56f1] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1uEjdB-0000000BZ6J-1oLb; Tue, 13 May 2025 07:00:49 +0000 From: Christoph Hellwig To: Keith Busch , Christoph Hellwig , Sagi Grimberg Cc: Caleb Sander Mateos , Leon Romanovsky , linux-nvme@lists.infradead.org Subject: [PATCH 7/7] nvme-pci: use struct_size for allocation struct nvme_dev Date: Tue, 13 May 2025 09:00:23 +0200 Message-ID: <20250513070025.830930-8-hch@lst.de> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250513070025.830930-1-hch@lst.de> References: <20250513070025.830930-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org This avoid open coding the variable size array arithmetics. Signed-off-by: Christoph Hellwig --- drivers/nvme/host/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 5396fe30eb94..0efbc9329291 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -3212,8 +3212,8 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev, struct nvme_dev *dev; int ret = -ENOMEM; - dev = kzalloc_node(sizeof(*dev) + nr_node_ids * - sizeof(*dev->descriptor_pools), GFP_KERNEL, node); + dev = kzalloc_node(struct_size(dev, descriptor_pools, nr_node_ids), + GFP_KERNEL, node); if (!dev) return ERR_PTR(-ENOMEM); INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work); -- 2.47.2