Permalink
Browse files

kernel/natapci - Fix a NULL pointer dereference.

- ata_devclass is NULL when no unit 0/1 is available or no
  legacy support has been detected.
- device_add_child() populates ata_devclass via make_device()
  so do not try to get information out of it when NULL.

Submitted-by: @dillon
  • Loading branch information...
1 parent 1a7bbca commit 40fa28485e51267b667cffb3cc801ee93a20bc48 @tuxillo tuxillo committed Feb 28, 2014
Showing with 5 additions and 3 deletions.
  1. +5 −3 sys/dev/disk/nata/ata-pci.c
View
8 sys/dev/disk/nata/ata-pci.c
@@ -246,9 +246,11 @@ ata_pci_attach(device_t dev)
continue;
}
/* XXX TGEN devclass_find_free_unit() implementation */
- while (freeunit < devclass_get_maxunit(ata_devclass) &&
- devclass_get_device(ata_devclass, freeunit) != NULL)
- freeunit++;
+ if (ata_devclass) {
+ while (freeunit < devclass_get_maxunit(ata_devclass) &&
+ devclass_get_device(ata_devclass, freeunit) != NULL)
+ freeunit++;
+ }
device_add_child(dev, "ata", freeunit);
}
bus_generic_attach(dev);

0 comments on commit 40fa284

Please sign in to comment.