Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp248731rdb; Tue, 31 Oct 2023 06:36:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG44DhC+mBkHog1FWMecoAP9xBjX2aPuFnC6DpqmGt2MVLeiqHfY7pjJJDdWKjsNZl8izSy X-Received: by 2002:a17:902:e5c5:b0:1cc:50ed:4931 with SMTP id u5-20020a170902e5c500b001cc50ed4931mr5000240plf.16.1698759399656; Tue, 31 Oct 2023 06:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698759399; cv=none; d=google.com; s=arc-20160816; b=opT5jNBrO9S5wd/0WbqFEQWclLIBFHRbzVypljblBSAjndxct7OqPEINFA0A9HOUl2 AOQ07DyxAMIz/LouYebE0vXEMemEjzF+1zXExUCYG8WI0rT/qfxuZBcq3LTxMOT+GhHl WtDAtgpSmtGElNTQftEEi/4d2IUEe2eiJj4ZIHt7w5umLkLcHVgCyxEFjFI0pHqjiILt ZAyClyqcuzqGs0tmFwMP5jMnPWYmZQnizRaOgnnuYH60zYnpBWiJYQNweHiQ5+10/rb5 wq4Nc80a1kDIJCq1cD8FoTQejbSqk0riOXK/LqLOSICEld9mWzNRLiedOnZPV5+z0D9m +htQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=0g16yPzYapF2f3kygmVwalJJMz4AExhb6XtYfwu8TYk=; fh=53UJZ3tyLqBP7qwMOB9EHrLYv5slTTdOsyuAmwGxftY=; b=k7nUOJhLf8ATuTqvCSJtFmgkpyIDea92oBoN1LWCmqbGPEHatraGoFCXQFtXdAL3FM 0GndNeVII5v0oKXrwHlR/NqRT0VHbMn74gnvzHZzQY0FaYGJYfplMp8UFv0w1VJul0M8 JIvlY01PGk8qGLoUh1aDIKZL3s3GIDqtuerHdkrGjm1JFE+eji+Q3HZJGxGVmJKK0a4A CpIRkbNAK5YxYWjaCo7WwyYCR4pwFtxDC9qMeS2/hMlsLOLfbT+zZ8J/LnGewLtEjPSZ C2B73qMOiH49QuVK3iHE1HtTqH4c3VEkJxcHREkb3OJ14HXK29/r/ZnTeVFmB65dHtl3 kXWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id iz11-20020a170902ef8b00b001c62d93585csi1009908plb.611.2023.10.31.06.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 06:36:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 011578075B18; Tue, 31 Oct 2023 06:36:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344589AbjJaNga convert rfc822-to-8bit (ORCPT + 99 others); Tue, 31 Oct 2023 09:36:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344559AbjJaNg3 (ORCPT ); Tue, 31 Oct 2023 09:36:29 -0400 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C048EA; Tue, 31 Oct 2023 06:36:27 -0700 (PDT) Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-582050ce2d8so519718eaf.0; Tue, 31 Oct 2023 06:36:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698759386; x=1699364186; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e2DPIqLf9ppE5aYoET2sqf9FsTqUrjaMI7dfyLVVvGw=; b=hpvRc3rmA8HgHczB8eEkKytss1nVN//SQE6z5HUBTsJWh/CVbGXeCZhdBAEb549ag5 /pnwdhXw32HybVfxlgXeIPLpCHC/WRBxCSdXI3csejP/woQM7WQ1tf5A6iVBvxKQqtfk rNb133R2ekCs0WICv/g/57PFGbORky1Y0ODr8v7VC39DBFTsV7Gs67wRolxPKTnglH26 exp31X4oXWJXXwQNs5+d5/+GQyOccJsUMTxb0vdHY63drIMqfEV993svP2YDBCVGVdRO AAv5WRGG+11OqplQRXM9RL+zYObglYNoiosx4pe/KQ82HwACs1kih1NuF6z0NZvECThn iFAw== X-Gm-Message-State: AOJu0YzGsn7cavGojbN1Mwhtjk9zgYfe+hKEpU1UiLewtluYQ+rPpF+o LSDtOJ/2TCxY5i20Is+Zms9dL05ZKnhhr88pVHo+Z98x X-Received: by 2002:a4a:4184:0:b0:57c:6e35:251e with SMTP id x126-20020a4a4184000000b0057c6e35251emr13200504ooa.1.1698759386437; Tue, 31 Oct 2023 06:36:26 -0700 (PDT) MIME-Version: 1.0 References: <2187487.irdbgypaU6@kreacher> <3288922.44csPzL39Z@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Tue, 31 Oct 2023 14:36:15 +0100 Message-ID: Subject: Re: [PATCH v2 2/6] ACPI: scan: Extract CSI-2 connection graph from _CRS To: Sakari Ailus Cc: "Rafael J. Wysocki" , Linux ACPI , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 06:36:37 -0700 (PDT) Hi Sakari, On Tue, Oct 31, 2023 at 11:33 AM Sakari Ailus wrote: > > 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. No problem.