From: jsg Date: Mon, 14 Feb 2022 05:20:03 +0000 (+0000) Subject: check return value of drm_attach_pci() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=99312d94c1f180664ddcfdbff29d993d72975cd3;p=openbsd check return value of drm_attach_pci() adapted from a diff by Ted Bullock --- diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c index 897686b2b49..27db010dc73 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_kms.c @@ -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; diff --git a/sys/dev/pci/drm/i915/i915_drv.c b/sys/dev/pci/drm/i915/i915_drv.c index 99c47441868..75131297847 100644 --- a/sys/dev/pci/drm/i915/i915_drv.c +++ b/sys/dev/pci/drm/i915/i915_drv.c @@ -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); diff --git a/sys/dev/pci/drm/radeon/radeon_kms.c b/sys/dev/pci/drm/radeon/radeon_kms.c index 4b82f391a99..24c87b265d9 100644 --- a/sys/dev/pci/drm/radeon/radeon_kms.c +++ b/sys/dev/pci/drm/radeon/radeon_kms.c @@ -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;