Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp100484rdb; Tue, 31 Oct 2023 01:48:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqimRlvQaqbogMzLNCs6MHVZmMAb8VkJuhrGHJgDRdW3Ej+35u4BmRPPPRYvYnrww89tmD X-Received: by 2002:a05:6808:2202:b0:3b2:e51a:a44d with SMTP id bd2-20020a056808220200b003b2e51aa44dmr15628363oib.34.1698742139359; Tue, 31 Oct 2023 01:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698742139; cv=none; d=google.com; s=arc-20160816; b=d+43La0FYdhH2u/0xFEpiNG2EbC55lemDZfkk6gcuL/YjOokUOK3rhYBzAHYaxAh7n L864WhQqw3n9XSvr+pYN7zift8WQ333HxSPqLy4NMW9+kuWKHQaGsfuEWa2bP6SsfCNE at4iR2msccl6S+/tnqodh1m27WtkUCZAYgMrBGeCWkIHg5D6FsKXcG+N1B4+O7LUMoRo 8PF3mVyQNkATaIB8WDwIGluvZdqmG4Zpo5QB+NfTibzazQ3GmAA/llsug/SbyLsd9WZi sVGTuIG2lS+wyiPa4k35Bqg2m3olcxE11JJw0dQ/CJsrb/ilVhV2v90Me5w3nXQqh7O5 Kucg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KFQ2FjysKuhLOzGTqvBj8Zi4dYCHTadwEDdjyVq5rq0=; fh=wxl7wP3hcSHx61OGwS6ASwqenQLYzU+oqwoBTAsym1Y=; b=P0OGcZ+ObeVun55zkFFFSE5jpUdY6JMt3zxXgHmoNy5yftanfoBLhetoVGNjePrVG2 Wwke/rMV33cWaLLNEaa6gn6r5EZmKKhaR3DxNdsqKaBMwE9DkDuXInwY7Es8NuLD7EY8 gmsWrvBEM7D32zqpinvwBkP0WZZhLQGgCOxBN7loa0XF4RSunCu3+NZAx9R2VvIDLsGX 8EoSNvOI7AX2xvFZzcR+yXZEk9UmW7GKwBDGSO/BzEGzpSn2sIZ14iq9mEr+4WcSy+TK 2rG+b6awwT31MndMd4uN9m9b1NkAg9yj6RI+Vs36hPDGNPwgQweQh0WZ5DuuxI2bEGKy QnoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LnXaAQV3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id g16-20020a056a000b9000b0068a5752a049si721770pfj.96.2023.10.31.01.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 01:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LnXaAQV3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 29831803D8CC; Tue, 31 Oct 2023 01:48:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235288AbjJaIsG (ORCPT + 99 others); Tue, 31 Oct 2023 04:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbjJaIsF (ORCPT ); Tue, 31 Oct 2023 04:48:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8110EDE; Tue, 31 Oct 2023 01:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698742078; x=1730278078; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=uXkV3vl3hug9NMYxNH3bPgLYMhjDGNYVTPifMu6ZOfk=; b=LnXaAQV3IAiYOa4BKNU3b60spvR1ujDl/N8eUbOpDHGoHZpJnyVIrTG5 xiWRCBoHGurl5i+YCFnAG7C7Tm+fVB9t4GucrQYjhPXI6fCd5WN6EQgo1 x3kSpoOrtVJFuTmr1E7GfCI6CMdqrQnAiT9vqi42UTtR2W5cB3KbP96lX rgmbhangmlVUnXwQCstdx8BDkSerYW8t16dSGB7qExfOJV6Bl3tGymdwI LzZwnPQ1dL7XsK8MikNXVyp4QulhDUDjbxOpzG+nR42RXv/EAOYrfZ1Px 8J10jl9INg7qgzCE5bUuY7WLFtp2TNw2Pzz+ggXxDukKG0tTT0StRxBDp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10879"; a="388061239" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="388061239" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 01:47:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10879"; a="754068685" X-IronPort-AV: E=Sophos;i="6.03,265,1694761200"; d="scan'208";a="754068685" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2023 01:47:56 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id C627011F894; Tue, 31 Oct 2023 10:47:53 +0200 (EET) Date: Tue, 31 Oct 2023 08:47:53 +0000 From: Sakari Ailus To: "Rafael J. Wysocki" Cc: Linux ACPI , LKML Subject: Re: [PATCH v2 2/6] ACPI: scan: Extract CSI-2 connection graph from _CRS Message-ID: References: <2187487.irdbgypaU6@kreacher> <3288922.44csPzL39Z@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3288922.44csPzL39Z@kreacher> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 01:48:53 -0700 (PDT) Hi Rafael, On Fri, Oct 20, 2023 at 04:36:28PM +0200, Rafael J. Wysocki wrote: > +#define NO_CSI2_PORT (UINT_MAX - 1) > + > +static void alloc_crs_csi2_swnodes(struct crs_csi2 *csi2) > +{ > + size_t port_count = csi2->port_count; > + struct acpi_device_software_nodes *swnodes; > + size_t alloc_size; > + unsigned int i; > + > + /* > + * Allocate memory for ports, node pointers (number of nodes + > + * 1 (guardian), nodes (root + number of ports * 2 (because for > + * every port there is an endpoint)). > + */ > + if (check_mul_overflow(sizeof(*swnodes->ports) + > + sizeof(*swnodes->nodes) * 2 + > + sizeof(*swnodes->nodeptrs) * 2, > + port_count, &alloc_size)) > + goto overflow; > + > + if (check_add_overflow(sizeof(*swnodes) + > + sizeof(*swnodes->nodes) + > + sizeof(*swnodes->nodeptrs) * 2, > + alloc_size, &alloc_size)) > + goto overflow; > + > + swnodes = kmalloc(alloc_size, GFP_KERNEL); > + if (!swnodes) > + return; > + > + swnodes->ports = (struct acpi_device_software_node_port *)(swnodes + 1); > + swnodes->nodes = (struct software_node *)(swnodes->ports + port_count); > + swnodes->nodeptrs = (const struct software_node **)(swnodes->nodes + 1 + > + 2 * port_count); > + swnodes->num_ports = port_count; > + > + for (i = 0; i < 2 * port_count + 1; i++) > + swnodes->nodeptrs[i] = &swnodes->nodes[i]; > + > + swnodes->nodeptrs[i] = NULL; > + > + for (i = 0; i < port_count; i++) > + swnodes->ports[i].port_nr = NO_CSI2_PORT; > + > + csi2->swnodes = swnodes; > + return; > + > +overflow: > + acpi_handle_info(csi2->handle, "too many _CRS CSI-2 resource handles (%zu)", > + port_count); I'd move this to where the conditions are, they can be merged. -- Regards, Sakari Ailus