From nobody Sun May 24 22:36:03 2026 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 C838C30B508 for ; Thu, 21 May 2026 01:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779327993; cv=none; b=ExfeoDvOE9jYXyxRruVHjR3oXvY27NRxfKeosbAlREsX4FxVwwS294VbUvGSz3UepDBNoOhORIc3ZK/k4qUSa9WNqegw8e6j0oaEesMzoGMSq/2yJ92pSI0KkPk8t0vNPlnSAuBB0Tqa2Jt83Hfl8OEKpaYDtIGmEs33RwH1s2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779327993; c=relaxed/simple; bh=K1oLwk3RTb4DmrtSS1Kd+fkh9y8M6HVo8S/ImeLc6e8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=t92tqsXWIiDr/6vEnIZ1K8gCO8Q63j49Drj47KJJi0pUpDBEbWoyL1xP4dk0RQTT5q4IigPz7RJKxgHKsItc5Q5xSi/8HFTi5qdfESDR9tb7/1HNuZURsgAdwtX2BZzxu9QLjfI0Md4lmBilWb/+WXeOOx07QINFKGHZTywj1Kg= 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=kpy5/Zed; arc=none smtp.client-ip=209.85.128.172 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="kpy5/Zed" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-7bdc947aaa3so52016077b3.0 for ; Wed, 20 May 2026 18:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779327987; x=1779932787; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JSOZPwggBd/tZaFmjqTfCM6sLL5sYIwg3J4tTfp4kIg=; b=kpy5/ZedTgdZuR3lB0USPng3wrpgkfLdCCC4EJMoFzaBrs3ZFhdezS8jMXR57qa912 azZG9wFMOGxzKWsmVaJXK7BrqJwYCTAEM3jHnLaM2I1wyCdQ2tw2MBRhylzK7HWiC8kP Zk6npQiX15570gVgpbRYLnaCbd9wx0soeAQvWI32XkIZcvoB62EBpWCuJuM6GGxkdG8w UdA/A9ZTE33z2FtAS5X9QfT25VUCGVwbkGzvB0gjq08yuyvTtr4AOETOaHD0uFrduaZ3 QTTsr1xoPQ3PTqAyeRnNLPGcOwdLKbPNeoGHwVXEMQ9Th0P2AwPKO6Lxnvk5gN0NNqHR wRZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779327987; x=1779932787; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JSOZPwggBd/tZaFmjqTfCM6sLL5sYIwg3J4tTfp4kIg=; b=JHyoo/YdQucQM4W0c5lbIIDI5NdFphVT62zU1dVapqR5/bWgnWyB5yxU5FpqKmIHEw 1ATmG+5dyjljYTQFNIpZ8lw5HEEqMP0z9toF0oKiSh6IZts/2XaIo+vZXY+ymMDgr4HU IaKgMVXIEL1S95+rihlj9J0zQEdbrkwghHFBS+8n91s7AQYHa9jP/2tU80fygsawMxcN Yl+qdwcDRJ07qXEDzaSs0EnaRtNVpg+8LzzHfoBuW7EEOVt2KGpJ859bGFqDZIQpl+87 Soxxuy0pIX5M5pDcAL/wk2JTGJxVKVP9OmhtjKy0DEL6YhSfxSju1sWaK30gto7I7xmV qfSw== X-Forwarded-Encrypted: i=1; AFNElJ/pnyP4QTm/8NYDAGqe1ofXN7NYNITePOEXXOolIKE1187iqGZQVz8g1gsUtXadX1zevUaV9Fe6sGH5vHk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7dn2YJ+u8oQOorGtT9JjLzm+SOQxQ2STLt0KCohRafXvLZ6Aw nqCPxgwjuNk4GaRGY9NT8ItL0AypnSOvEEVWx44H7Gz7GRoUF7wwocHk X-Gm-Gg: Acq92OF66eQDEsn9LzCZYZeUiVlW+ga95sX6fxcXtuEMW116V06fYdvFOZWuTnomwfP 5JckyAIbKLJHY8Ts4TyhzDHX3pZHXrRoKznlGR8osgEp9b0hjjqhGpiA4RLwWScnhKsXKmpUzp7 63WC7De3TrGqHlojR7M1w9BsDSIbK92/0NDagzrHNknXzVo1ZYOVm4BC4NFGZWFqTK+a+QtYXQW /qTqwfyhgnzRUqdoNpv7JEgIH4zlmfgnEFEOVvpFv8rp+YgnkDJgogD2m4gyIuQa9a8EYksOMK2 IfqV2oa0L0BJuG4WnjVXkgbLrX8iPXrFHOZH4/V8r7kBgWR27WdNM2hZhh5onZW1MeqKlOcX8P1 cVBBr0/fVU75n+Z+HFTWFb6/N42bvrPMYPihVf32rFR6K4Uy+gRH+NdaQ49KhJu2YPVBxZFWFc2 +03J9fxwqontoYgmnh0DE8ZqZzn/4qlb3n+QM/NcO0I8mua6RKaJDLgxSp0bj1O2GrjYDmLw5rm u9LKUCypaBVp/QKgxTnI+cxeq5a8SpiKJs= X-Received: by 2002:a05:690c:4b0c:b0:7bf:ff7:ea72 with SMTP id 00721157ae682-7d20d020f3dmr10604927b3.34.1779327986944; Wed, 20 May 2026 18:46:26 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7cd0bfdc094sm56652417b3.32.2026.05.20.18.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 18:46:26 -0700 (PDT) From: Rosen Penev To: platform-driver-x86@vger.kernel.org Cc: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Kees Cook , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org (open list), linux-hardening@vger.kernel.org (open list:KERNEL HARDENING (not covered by other areas):Keyword:\b__counted_by(_le|_be|_ptr)?\b) Subject: [PATCHv2] platform/x86/intel/tpmi/plr: allocate die_info with plr Date: Wed, 20 May 2026 18:46:08 -0700 Message-ID: <20260521014608.1356671-1-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplifies allocations slightly. Add __counted_by for extra runtime analysis. Signed-off-by: Rosen Penev --- v2: Rebase. drivers/platform/x86/intel/plr_tpmi.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/intel/plr_tpmi.c b/drivers/platform/x86/i= ntel/plr_tpmi.c index 8faecc311038..66220fadf670 100644 --- a/drivers/platform/x86/intel/plr_tpmi.c +++ b/drivers/platform/x86/intel/plr_tpmi.c @@ -58,11 +58,11 @@ struct tpmi_plr_die { =20 struct tpmi_plr { struct dentry *dbgfs_dir; - struct tpmi_plr_die *die_info; int num_dies; struct auxiliary_device *auxdev; struct notifier_block nb; struct mutex lock; /* Protect access to dbgfs_dir */ + struct tpmi_plr_die die_info[] __counted_by(num_dies); }; =20 static const char * const plr_coarse_reasons[] =3D { @@ -305,7 +305,7 @@ static int intel_plr_probe(struct auxiliary_device *aux= dev, const struct auxilia if (!num_resources) return -EINVAL; =20 - plr =3D devm_kzalloc(&auxdev->dev, sizeof(*plr), GFP_KERNEL); + plr =3D devm_kzalloc(&auxdev->dev, struct_size(plr, die_info, num_resourc= es), GFP_KERNEL); if (!plr) return -ENOMEM; =20 @@ -315,13 +315,6 @@ static int intel_plr_probe(struct auxiliary_device *au= xdev, const struct auxilia =20 intel_plr_register_notifier(&plr->nb); =20 - plr->die_info =3D devm_kcalloc(&auxdev->dev, num_resources, sizeof(*plr->= die_info), - GFP_KERNEL); - if (!plr->die_info) { - err =3D -ENOMEM; - goto err_notify; - } - plr->num_dies =3D num_resources; plr->dbgfs_dir =3D debugfs_create_dir("plr", dentry); plr->auxdev =3D auxdev; @@ -361,7 +354,6 @@ static int intel_plr_probe(struct auxiliary_device *aux= dev, const struct auxilia =20 err: debugfs_remove_recursive(plr->dbgfs_dir); -err_notify: intel_plr_unregister_notifier(&plr->nb); =20 return err; --=20 2.54.0