Skip to content

Commit

Permalink
drivers/pci: add error handle for pci_alloc_bus/device()
Browse files Browse the repository at this point in the history
Signed-off-by: Bowen Wang <[email protected]>
  • Loading branch information
CV-Bowen authored and xiaoxiang781216 committed Sep 27, 2024
1 parent e8f6b1e commit fd182da
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ static FAR struct pci_bus_s *pci_alloc_bus(void)
FAR struct pci_bus_s *bus;

bus = kmm_zalloc(sizeof(*bus));
if (bus == NULL)
{
return NULL;
}

list_initialize(&bus->node);
list_initialize(&bus->children);
Expand All @@ -580,6 +584,10 @@ static FAR struct pci_device_s *pci_alloc_device(void)
FAR struct pci_device_s *dev;

dev = kmm_zalloc(sizeof(*dev));
if (dev == NULL)
{
return NULL;
}

list_initialize(&dev->node);
list_initialize(&dev->bus_list);
Expand Down Expand Up @@ -2069,6 +2077,11 @@ int pci_register_controller(FAR struct pci_controller_s *ctrl)
}

bus = pci_alloc_bus();
if (bus == NULL)
{
return -ENOMEM;
}

bus->ctrl = ctrl;

ctrl->bus = bus;
Expand Down

0 comments on commit fd182da

Please sign in to comment.