From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 829CB34CFBA for ; Mon, 23 Feb 2026 23:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771889671; cv=none; b=FFN2Amp2nhyhQqGreWFiudU8nHov9cMfuzq51mxfqzq51ODbIMTAgNz5mSNmNSlQJKvEgqUY/3s99mluXbNBSVUUu3sKJEuUmOZU6vfPRI0bNYdJGXNyIN+4GyYciISmP+f6a3xHgb8s9yKqWwuQJ2Cm+pC3caG96wdhwciq974= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771889671; c=relaxed/simple; bh=pciwHYBXFB6v/vUAo2tH4GtOQRnTkny9zpmgBJVAQDA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tTM0CaZAL7sbQJ3Fzb/3tmC6XYro8YRDsOUqN2XlVIK9EY+sbNWaErT6AcZFnmpyl9TiaBrf/bU+wovk8OeqFuJhRGspiZ0oCTRIomhUa/e/A0/4jmugumpK3UhS6ImYzQXW8O//FbBq7R36nLXqf2hn3E0rBHV6gW4IKzuLmHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Dl+GhZpe; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Dl+GhZpe" 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=1771889668; 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; bh=n90OW/otD7lsfZE/MLcmeBPOW3B5AGA8tFtKamYFmAE=; b=Dl+GhZpesQ67jJEcMhTvgf8exYc1C4a8IY85QwoD9nr9dDhk5DFjFGfXaGV6NGyqgSySB3 J91/WLZggRE/XWLsFfjQBEn6UCqaq/AiKNQ9OdXKE6cLvMCEX/wZ9zp2d48DzZD72gvs/S RySFKpe/V/OcxFoZwab00f7fNnJPUac= From: Thorsten Blum To: Marcel Holtmann , Luiz Augusto von Dentz Cc: Thorsten Blum , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Bluetooth: btintel_pcie: Use struct_size to improve hci_drv_read_info Date: Tue, 24 Feb 2026 00:33:42 +0100 Message-ID: <20260223233341.426067-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Use struct_size(), which provides additional compile-time checks for structures with flexible array members (e.g., __must_be_array()), to determine the allocation size for a new 'struct hci_drv_rp_read_info'. Signed-off-by: Thorsten Blum --- drivers/bluetooth/btintel_pcie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c index eda243988cfd..473b2115e637 100644 --- a/drivers/bluetooth/btintel_pcie.c +++ b/drivers/bluetooth/btintel_pcie.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -2373,7 +2374,7 @@ static int btintel_pcie_hci_drv_read_info(struct hci_dev *hdev, void *data, u16 opcode, num_supported_commands = ARRAY_SIZE(btintel_pcie_hci_drv_supported_commands); - rp_size = sizeof(*rp) + num_supported_commands * 2; + rp_size = struct_size(rp, supported_commands, num_supported_commands); rp = kmalloc(rp_size, GFP_KERNEL); if (!rp) -- Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4