On 2/7/2025 1:41 PM, Gregory Price wrote: > On Fri, Feb 07, 2025 at 01:23:06PM -0600, Bowman, Terry wrote: >> >> On 2/7/2025 2:01 AM, Gregory Price wrote: >>> On Tue, Jan 07, 2025 at 08:38:49AM -0600, Terry Bowman wrote: >>>> +static void __iomem *cxl_pci_port_ras(struct pci_dev *pdev) >>>> +{ >>>> + struct cxl_port *port; >>>> + >>>> + if (!pdev) >>>> + return NULL; >>>> + >>>> + if ((pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) || >>>> + (pci_pcie_type(pdev) == PCI_EXP_TYPE_DOWNSTREAM)) { >>>> + struct cxl_dport *dport; >>>> + void __iomem *ras_base; >>>> + >>>> + port = find_cxl_port(&pdev->dev, &dport); >>>> + ras_base = dport ? dport->regs.ras : NULL; >>> I'm fairly certain dport can come back here uninitialized, you >>> probably want to put this inside the `if (port)` block and >>> pre-initialize dport to NULL. >> Right, it can. NULL dport check here covers this, no?: >> >> ras_base = dport ? dport->regs.ras : NULL; > dport can be garbage (whatever is on the stack) at this check because > nothing ever intializes it to NULL. Got it. Thanks. >> Terry >> >>>> + if (port) >>>> + put_device(&port->dev); >>>> + return ras_base; >>> You can probably even simplify this down to something like >>> >>> struct_cxl_dport *dport = NULL; >>> >>> port = find_cxl_port(&pdev->dev, &dport); >>> if (port) >>> put_device(&port->dev); >>> >>> return dport ? dport->regs.ras : NULL; >>> >>> >>> ~Gregory