change a NULL pa_memex test after use to an earlier KASSERT
authorjsg <jsg@openbsd.org>
Mon, 14 Feb 2022 03:51:42 +0000 (03:51 +0000)
committerjsg <jsg@openbsd.org>
Mon, 14 Feb 2022 03:51:42 +0000 (03:51 +0000)
from Ted Bullock

sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c
sys/dev/pci/drm/radeon/radeon_kms.c

index 720a0fd..897686b 100644 (file)
@@ -1782,14 +1782,15 @@ amdgpu_attach(struct device *parent, struct device *self, void *aux)
                bus_size_t start, end, pci_mem_end;
                bus_addr_t base;
 
+               KASSERT(pa->pa_memex != NULL);
+
                start = max(PCI_MEM_START, pa->pa_memex->ex_start);
                if (PCI_MAPREG_MEM_TYPE(type) == PCI_MAPREG_MEM_TYPE_64BIT)
                        pci_mem_end = PCI_MEM64_END;
                else
                        pci_mem_end = PCI_MEM_END;
                end = min(pci_mem_end, pa->pa_memex->ex_end);
-               if (pa->pa_memex == NULL ||
-                   extent_alloc_subregion(pa->pa_memex, start, end,
+               if (extent_alloc_subregion(pa->pa_memex, start, end,
                    adev->fb_aper_size, adev->fb_aper_size, 0, 0, 0, &base)) {
                        printf(": can't reserve framebuffer space\n");
                        return;
index a2d53f7..bd1951c 100644 (file)
@@ -556,10 +556,11 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux)
                bus_size_t start, end;
                bus_addr_t base;
 
+               KASSERT(pa->pa_memex != NULL);
+
                start = max(PCI_MEM_START, pa->pa_memex->ex_start);
                end = min(PCI_MEM_END, pa->pa_memex->ex_end);
-               if (pa->pa_memex == NULL ||
-                   extent_alloc_subregion(pa->pa_memex, start, end,
+               if (extent_alloc_subregion(pa->pa_memex, start, end,
                    rdev->fb_aper_size, rdev->fb_aper_size, 0, 0, 0, &base)) {
                        printf(": can't reserve framebuffer space\n");
                        return;