From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3C3F42314B for ; Tue, 20 Jan 2026 11:30:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768908639; cv=none; b=LEHJGn3ZI32KMskPWboNOafcU5RzCqvyOi0aceAJlUKq2wLfbwQa9cb2ef+MzIPufFeI5EqQxWcJ/aUxBOmBCtqxG9s8Uv+0J7QMyFq1+EEPh8bRzgLwMlHsQV6PbbP771cv3ENGgkfmy1dmzQ9wkIHBetf33ZBeh0lWqMHciaU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768908639; c=relaxed/simple; bh=XKnFz3WuMpGZEHRlcmsh+dYpDAnDUCFAxevhkpA0raM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NgzMywqah0uCTQ+etY4A2RFpzXqcApL9Y152FwNGUH+7R12+Q0ZEx/IkLGuUI9Y33LcWOn8MqqZ8p+UisogWdc6nld2+7X9TPU5QV4hfDfA+jvU+wU8AjR4WaqFWNCRTTlpSrWNJCwOu9+i2n1ieOlkynsuVnCfjWHtRB0Xr0wE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E3wo1xEz; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E3wo1xEz" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-34f63ad6f51so2305697a91.0 for ; Tue, 20 Jan 2026 03:30:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768908636; x=1769513436; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OFhodcvRDH7q+MwCRWTVNOvZ9XPVdXXYbq7DeVi+2lE=; b=E3wo1xEzzXk2QOyoSzGKeHJ5DACJQXc4rLSe+7L0fSPZvsrlv8B/G22SfDdbF6FHga CtR8o6VXxDMe5Mf34c19MgVfxtvkFe4IASIiXceM14Y3Ujufduo2tOcnTbJJOeUvGdXB CbPSnPjsYgsGqOMYVZ0/5Vgp+lQW/YGiE6yUUueqA0VdJFbX4sZYcKppHns9lQTVt7Gs FhU4s2QjIrt7ENVz8yQsw6PVjFQ7YJczUVUrOfj4pA7JHxHVicjElN4f6zUjX/QRrDw4 v1X1ROTlEUxtl78AcOWoPzsh39NOUzVhyNz8WHq0fL7W1p6tgihYzLxybDwcx/nv0+H1 lsog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768908636; x=1769513436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OFhodcvRDH7q+MwCRWTVNOvZ9XPVdXXYbq7DeVi+2lE=; b=Fn12LPU0TOs/Eh0IwXqUy6lfMDXfej3FpXiOR/K9Uiv9FJ5tShS3L1IY/TI6d3yQhM Wp61B/GMFFOn3cB+Y5YDyS/h9vuBVocoCp/ltm7nwLBvR+hmVVNlPRXUp5com3dtN4Ub Iz6X/6b51sQwBgm7z6QsAf5w5CldK8o1IERmPaqaVn+dWHb6BeJwsHtHVLVgbK8XaugH WfNdSNINPi18u+JS2B4jd7LOIrJ4DiNw10QdQhTMVE6hQyixRHZxqfClMDKe4Zx0UWnN /FNJjevP5OBH70Uj5HKuzU9pNVCrJs10x03elkwX5dYKPl0RztJuZ/abvw3rZMEGO6rm O20g== X-Forwarded-Encrypted: i=1; AJvYcCW4lo/UPYtiED9qBjHSvXs2lP2MsRsb1/22VWy0xcFs8rGH7D5FDu0F7rpPKpxoVw+h1Ijpj9rhz3/3ZFk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+acFYh0EtSzQ3+dY9sdvLgBLYbVtSQRtBFapYM96FSDmBsNPE Rozn2SbwIVsU/UW8vDcytqlA5n9TpG0XMJzgjD/slLW0pEIiNUK6+fKy X-Gm-Gg: AZuq6aIfvjBN+XEJwqdZNYCT230XGX920HGVZbEs7EndzxNOoglu5c4EUY0A7w3vsk9 g4ZXnfERNuMac3wvK5VquLXyoROCwkBUphUOdKstOL/JHIYYwVrrYATqVG0iUHKxpufnLrLrBB7 /pJraUnI/mlno2BWJSZSoqx+KDxCGiPxg88Gbsu1B6AlD72JX+PmSQWpOb5C1SCGiqVtWWys+Q5 a7zyoZ9PWNZFtfA28QT7bMMgve3ftVpwKpElrsHpM45WnK6RwlgJZs0Dxlo0+RlSBf5py6NW6RU XbyjbMjqnhckwSH9VOZQc9RS3lJyLdL7MHYHx+54h0xKPeEzXl6xEg9qYnmxs6oAvaX0fa+D+iu xIGxn9ABi+pxCVaNhLP1LQXZJKuEqbCLx4Wsk7roIVJByPchi0tVsiW21dm3OWVny88LggasOst 9gMsipI3Tf8Tq1bOhIB5MUAW3m7+Jfru+A2q7TCXtYPSYkwStSKvTu7Q== X-Received: by 2002:a17:90b:3f44:b0:341:315:f4ed with SMTP id 98e67ed59e1d1-352c3e4a4c3mr1362569a91.10.1768908636143; Tue, 20 Jan 2026 03:30:36 -0800 (PST) Received: from nwang-tw.host.com ([124.127.58.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-352d57a56f2sm1045900a91.15.2026.01.20.03.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 03:30:35 -0800 (PST) From: iamhswang@gmail.com To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net, akpm@linux-foundation.org, dave.hansen@linux.intel.com, tiwei.btw@antgroup.com, rppt@kernel.org, kevin.brodsky@arm.com, snovitoll@gmail.com, linux@weissschuh.net Cc: linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, iamhswang@gmail.com Subject: [PATCH 2/2] um: use uml_kmalloc_array() instead of uml_malloc() Date: Tue, 20 Jan 2026 19:28:55 +0800 Message-ID: <20260120112938.463596-2-iamhswang@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260120112938.463596-1-iamhswang@gmail.com> References: <20260120112938.463596-1-iamhswang@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Haisu Wang Replace uml_kmalloc() with uml_kmalloc_array() for multiplication. Signed-off-by: Haisu Wang --- arch/um/drivers/vector_user.c | 4 ++-- arch/um/drivers/vfio_user.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c index 2ea67e6fd067..adc4280691cf 100644 --- a/arch/um/drivers/vector_user.c +++ b/arch/um/drivers/vector_user.c @@ -868,8 +868,8 @@ void *uml_vector_default_bpf(const void *mac) } else { return NULL; } - bpf = uml_kmalloc( - sizeof(struct sock_filter) * DEFAULT_BPF_LEN, UM_GFP_KERNEL); + bpf = uml_kmalloc_array(DEFAULT_BPF_LEN, sizeof(struct sock_filter), + UM_GFP_KERNEL); if (bpf) { bpf_prog->filter = bpf; /* ld [8] */ diff --git a/arch/um/drivers/vfio_user.c b/arch/um/drivers/vfio_user.c index 6a45d8e14582..4ad8c8c59e9d 100644 --- a/arch/um/drivers/vfio_user.c +++ b/arch/um/drivers/vfio_user.c @@ -194,7 +194,7 @@ int uml_vfio_user_setup_device(struct uml_vfio_user_device *dev, if (dev->num_regions > VFIO_PCI_CONFIG_REGION_INDEX + 1) dev->num_regions = VFIO_PCI_CONFIG_REGION_INDEX + 1; - dev->region = uml_kmalloc(sizeof(*dev->region) * dev->num_regions, + dev->region = uml_kmalloc_array(dev->num_regions, sizeof(*dev->region), UM_GFP_KERNEL); if (!dev->region) { err = -ENOMEM; @@ -223,7 +223,7 @@ int uml_vfio_user_setup_device(struct uml_vfio_user_device *dev, dev->irq_count = irq_info.count; - dev->irqfd = uml_kmalloc(sizeof(int) * dev->irq_count, UM_GFP_KERNEL); + dev->irqfd = uml_kmalloc_array(dev->irq_count, sizeof(int), UM_GFP_KERNEL); if (!dev->irqfd) { err = -ENOMEM; goto free_region; -- 2.52.0