Re: [PATCH v2] of/address: Fix NULL bus dereference in of_pci_range_parser_one()

From: Carlo Caione

Date: Fri Jul 17 2026 - 07:18:10 EST


On Thu Jul 16, 2026 at 10:49 PM CEST, Rob Herring wrote:
> On Mon, Jul 06, 2026 at 01:47:17PM +0200, Carlo Caione wrote:

...
>> ranges = of_get_property(np, "dma-ranges", &len);
>> - if (ranges && len) {
>> - of_dma_range_parser_init(&parser, np);
>> + if (ranges && len && !of_dma_range_parser_init(&parser, np) &&
>> + of_range_count(&parser)) {
>
> Why do we need of_range_count() here?

too zelous but this hopefully covers the case where init succeeds but
the property holds no complete entry, so the loop never runs. E.g. a
32-bit style triplet on a 2/2-cells bus:

soc {
#address-cells = <2>;
#size-cells = <2>;
dma-ranges = <0x0 0x40000000 0x40000000>;
};

It is unlikely and a pre-existing problem so I can drop it if you want.

cheers,

--
Carlo Caione