Skip to content

of/irq: Fix MSI map walk regression and NULL deref in of_msi…#1017

Closed
vijayanandjitta-oss wants to merge 0 commit intoqualcomm-linux:tech/mem/iommufrom
vijayanandjitta-oss:msi-map-fix
Closed

of/irq: Fix MSI map walk regression and NULL deref in of_msi…#1017
vijayanandjitta-oss wants to merge 0 commit intoqualcomm-linux:tech/mem/iommufrom
vijayanandjitta-oss:msi-map-fix

Conversation

@vijayanandjitta-oss
Copy link
Copy Markdown

@vijayanandjitta-oss vijayanandjitta-oss commented Apr 23, 2026

Commit a4503c1 ("FROMLIST: of: Factor arguments passed to of_map_id() into a struct") refactored of_map_id() to use an explicit filter_np parameter instead of the dual-purpose struct device_node **target pointer.

The old API distinguished three cases via the double pointer:

  • target == NULL -> pass-through (return 0) when no msi-map
  • target != NULL, *target == NULL -> return -ENODEV (walk continues)
  • target != NULL, *target != NULL -> filter by *target

In of_msi_xlate(), the call was changed from passing &np (always a non-NULL pointer, with *np initially NULL) to passing *msi_np (the dereferenced value, initially NULL). This collapsed the "pointer-but-no-filter-yet" case into "no filter at all", causing of_map_id() to return 0 (pass-through) instead of -ENODEV when a node has no msi-map property.

Back in of_msi_xlate(), a return value of 0 triggers break, terminating the walk at the first node (e.g., a PCIe port or endpoint) before ever reaching the root complex node that has the msi-map. As a result, *msi_np remains NULL, irq_find_matching_host() returns NULL, and no MSI domain is associated with the device.

This affects all callers that start with *msi_np == NULL:

  • of_msi_map_get_device_domain(): MSI domain not found for PCIe devices
  • pci_msi_map_rid_ctlr_node(): MSI controller node not found
  • iproc_pcie_setup_msi(): returns -ENODEV

Additionally, fsl_mc_get_msi_id() passes msi_np == NULL directly to of_msi_xlate(), causing a NULL pointer dereference when the function tries to dereference *msi_np.

Fix both issues in of_msi_xlate():

  1. Walk regression: after of_map_msi_id() returns 0, check msi_spec.np. A NULL np indicates a pass-through result (no msi-map on this node), so continue walking up the device hierarchy rather than breaking.

  2. NULL msi_np: introduce a local fallback pointer using the __free(device_node) cleanup attribute (consistent with existing usage in this file). When msi_np is NULL, np points to local_np instead, allowing the walk to proceed safely. Any reference acquired is released automatically on function return.

This PR picks the v14 series which includes the fix for above issue.

CRs-Fixed: 4513046

@quic-guptap
Copy link
Copy Markdown

Please post the fix to upstream.

@qcomlnxci qcomlnxci requested review from a team and quic-guptap and removed request for a team April 24, 2026 07:11
@vijayanandjitta-oss vijayanandjitta-oss changed the title PENDING: of/irq: Fix MSI map walk regression and NULL deref in of_msi… of/irq: Fix MSI map walk regression and NULL deref in of_msi… Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants