lkml.org 
[lkml]   [2023]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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@linux.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.

\
 
 \ /
  Last update: 2023-10-31 14:37    [W:0.098 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site