Skip to contentSkip to conversation

samples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe()

PATCH Superseded Shang XiaoJing 2 participants 3 messages Dec 7, 2022 – Dec 8, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 samples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe()

Add missing pci_disable_device() in fail path of mdpy_fb_probe().

Fixes cacade1946a4 ("sample: vfio mdev display - guest driver")
---
 samples/vfio-mdev/mdpy-fb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
samples/vfio-mdev/mdpy-fb.c +4 -1
index 9ec93d90e8a5..a7b3a30058e5 100644
@@ -109,7 +109,7 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
 
 	ret = pci_request_regions(pdev, "mdpy-fb");
 	if (ret < 0)
-		return ret;
+		goto err_disable_dev;
 
 	pci_read_config_dword(pdev, MDPY_FORMAT_OFFSET, &format);
 	pci_read_config_dword(pdev, MDPY_WIDTH_OFFSET,	&width);
@@ -191,6 +191,9 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
 err_release_regions:
 	pci_release_regions(pdev);
 
+err_disable_dev:
+	pci_disable_device(pdev);
+
 	return ret;
 }
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 22 lines · On Wed, 7 Dec 2022 15:21:28 +0800 Shang XiaoJing <[email protected]>…

Add missing pci_disable_device() in fail path of mdpy_fb_probe().

Fixes cacade1946a4 ("sample: vfio mdev display - guest driver")
---
 samples/vfio-mdev/mdpy-fb.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
samples/vfio-mdev/mdpy-fb.c +1 -1
index 9ec93d90e8a5..a7b3a30058e5 100644
@@ -109,7 +109,7 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
 
 	ret = pci_request_regions(pdev, "mdpy-fb");
 	if (ret < 0)
-		return ret;
+		goto err_disable_dev;
 
 	pci_read_config_dword(pdev, MDPY_FORMAT_OFFSET, &format);
 	pci_read_config_dword(pdev, MDPY_WIDTH_OFFSET,	&width);

samples/vfio-mdev/mdpy-fb.c static int mdpy_fb_probe(struct pci_dev *pdev, · line 199

Quoted 9 lines
samples/vfio-mdev/mdpy-fb.c +3 -0
@@ -191,6 +191,9 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
 err_release_regions:
 	pci_release_regions(pdev);
 
+err_disable_dev:
+	pci_disable_device(pdev);
+
 	return ret;
 }
 

What about the same in the .remove callback? Seems that all but the framebuffer unwind is missing in the remove path. Thanks,

Alex

#2 lore raw
Quoted 28 lines · Alex Williamson
Quoted 25 lines · On Wed, 7 Dec 2022 15:21:28 +0800 Shang XiaoJing <[email protected]>…

Add missing pci_disable_device() in fail path of mdpy_fb_probe().

Fixes cacade1946a4 ("sample: vfio mdev display - guest driver")
---
  samples/vfio-mdev/mdpy-fb.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
samples/vfio-mdev/mdpy-fb.c +1 -1
index 9ec93d90e8a5..a7b3a30058e5 100644
@@ -109,7 +109,7 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
 
  	ret = pci_request_regions(pdev, "mdpy-fb");
  	if (ret < 0)
-		return ret;
+		goto err_disable_dev;
 
  	pci_read_config_dword(pdev, MDPY_FORMAT_OFFSET, &format);
  	pci_read_config_dword(pdev, MDPY_WIDTH_OFFSET,	&width);
@@ -191,6 +191,9 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
  err_release_regions:
  	pci_release_regions(pdev);
 
Quoted 10 lines

samples/vfio-mdev/mdpy-fb.c static int mdpy_fb_probe(struct pci_dev *pdev, · line 199

Quoted 6 lines
samples/vfio-mdev/mdpy-fb.c +3 -0
+err_disable_dev:
+	pci_disable_device(pdev);
+
  	return ret;
  }
 

What about the same in the .remove callback? Seems that all but the framebuffer unwind is missing in the remove path. Thanks,

Right, will fix in v2.

Thanks for the review,

Signature · 1 line
Shang XiaoJing