Skip to contentSkip to conversation

drm/amd/amdgpu: handle return value of amdgpu_driver_load_kms

PATCH In review Liu ChengZhe 3 participants 3 messages Jun 9, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: handle return value of amdgpu_driver_load_kms

if guest driver failed to enter full GPU access, amdgpu_driver_load_kms will unload kms and free dev->dev_private, drm_dev_register would access null pointer. Driver will enter an error state and can't be unloaded.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -1
index 667aad1f15c0..9c81a3d0b546 100644
@@ -1165,7 +1165,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 
 	pci_set_drvdata(pdev, dev);
 
-	amdgpu_driver_load_kms(dev, ent->driver_data);
+	ret = amdgpu_driver_load_kms(dev, ent->driver_data);
+	if (ret)
+		goto err_pci;
 
 retry_init:
 	ret = drm_dev_register(dev, ent->driver_data);
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by Nirmoy Das on v1 1/1
#1 lore raw
Quoted 14 lines · Liu ChengZhe

if guest driver failed to enter full GPU access, amdgpu_driver_load_kms will unload kms and free dev->dev_private, drm_dev_register would access null pointer. Driver will enter an error state and can't be unloaded.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
index 667aad1f15c0..9c81a3d0b546 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pci_probe(struct pci_dev *pdev, · line 1173

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -1
@@ -1165,7 +1165,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 
  	pci_set_drvdata(pdev, dev);
 
-	amdgpu_driver_load_kms(dev, ent->driver_data);
+	ret = amdgpu_driver_load_kms(dev, ent->driver_data);
+	if (ret)
+		goto err_pci;
 
  retry_init:
  	ret = drm_dev_register(dev, ent->driver_data);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
In reply to Liu ChengZhe

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Liu ChengZhe
Sent: Tuesday, June 9, 2020 2:50 PM
To: [email protected]
Cc: Liu, Cheng Zhe <[email protected]>
Subject: [PATCH] drm/amd/amdgpu: handle return value of amdgpu_driver_load_kms

[CAUTION: External Email]

if guest driver failed to enter full GPU access, amdgpu_driver_load_kms will unload kms and free dev->dev_private, drm_dev_register would access null pointer. Driver will enter an error state and can't be unloaded.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -1
index 667aad1f15c0..9c81a3d0b546 100644
@@ -1165,7 +1165,9 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 
        pci_set_drvdata(pdev, dev);
 
-       amdgpu_driver_load_kms(dev, ent->driver_data);
+       ret = amdgpu_driver_load_kms(dev, ent->driver_data);
+       if (ret)
+               goto err_pci;
 

Looks good to me. Reviewed-by: Madhav Chauhan <[email protected]>

retry_init:

        ret = drm_dev_register(dev, ent->driver_data);

--
2.25.1

_______________________________________________
amd-gfx mailing list
mailto:[email protected]
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx