[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0gU10X67sa74gqmK9MHVi-uBFGjEGHRySXL5LwWUF5o9g@mail.gmail.com>
Date: Tue, 31 Oct 2023 14:36:15 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Sakari Ailus <sakari.ailus@...ux.intel.com>
Cc: "Rafael J. Wysocki" <rjw@...ysocki.net>,
Linux ACPI <linux-acpi@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/6] ACPI: scan: Extract CSI-2 connection graph from _CRS
Hi Sakari,
On Tue, Oct 31, 2023 at 11:33 AM Sakari Ailus
<sakari.ailus@...ux.intel.com> 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.
Powered by blists - more mailing lists