Re: [PATCH v7 7/9] PCI/IDE: Add IDE establishment helpers

Aneesh Kumar K.V
2025-10-25T16:53:55Z

Dan Williams <dan.j.williams@intel.com> writes:
...

> +DEFINE_FREE(free_stream, struct stream_index *, if (_T) free_stream_index(_T))
> +static struct stream_index *alloc_stream_index(struct ida *ida, u8 max,
> + struct stream_index *stream)
> +{
> + int id;
> +
> + if (!max)
> + return NULL;
> +
> + id = ida_alloc_range(ida, 0, max - 1, GFP_KERNEL);
> + if (id < 0)
> + return NULL;
> +
> + *stream = (struct stream_index) {
> + .ida = ida,
> + .stream_index = id,
> + };
> + return stream;
> +}
> +

We do

struct stream_index *hb_stream __free(free_stream) = alloc_stream_index(
&hb->ide_stream_ida, hb->nr_ide_streams, &__stream[PCI_IDE_HB]);

and the default value for hb->nr_ide_streams is 256

void pci_ide_init_host_bridge(struct pci_host_bridge *hb)
{
hb->nr_ide_streams = 256;
}

That overflows the u8 max argument for alloc_stream_index and results in
a NULL return.

-aneesh