check return value of drm_attach_pci()
authorjsg <jsg@openbsd.org>
Mon, 14 Feb 2022 05:20:03 +0000 (05:20 +0000)
committerjsg <jsg@openbsd.org>
Mon, 14 Feb 2022 05:20:03 +0000 (05:20 +0000)
adapted from a diff by Ted Bullock

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

index 897686b..27db010 100644 (file)
@@ -1873,6 +1873,10 @@ amdgpu_attach(struct device *parent, struct device *self, void *aux)
 
        dev = drm_attach_pci(&amdgpu_kms_driver, pa, 0, adev->primary,
            self, &adev->ddev);
+       if (dev == NULL) {
+               printf("%s: drm attach failed\n", adev->self.dv_xname);
+               return;
+       }
        adev->pdev = dev->pdev;
        adev->is_fw_fb = adev->primary;
 
index 99c4744..7513129 100644 (file)
@@ -2397,6 +2397,10 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
 
        dev = drm_attach_pci(&driver, pa, 0, dev_priv->primary,
            self, &dev_priv->drm);
+       if (dev == NULL) {
+               printf("%s: drm attach failed\n", dev_priv->sc_dev.dv_xname);
+               return;
+       }
 
        id = drm_find_description(PCI_VENDOR(pa->pa_id),
            PCI_PRODUCT(pa->pa_id), pciidlist);
index 4b82f39..24c87b2 100644 (file)
@@ -656,6 +656,10 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux)
 
        dev = drm_attach_pci(&kms_driver, pa, is_agp, rdev->primary,
            self, NULL);
+       if (dev == NULL) {
+               printf("%s: drm attach failed\n", rdev->self.dv_xname);
+               return;
+       }
        rdev->ddev = dev;
        rdev->pdev = dev->pdev;