Skip to contentSkip to conversation

drm/amdgpu: fix pci device refcount leak

PATCH Applied Yang Yingliang 3 participants 3 messages Nov 17, 2022 – Nov 18, 2022

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

PATCH 1/1 drm/amdgpu: fix pci device refcount leak

As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put().

So before returning from amdgpu_device_resume|suspend_display_audio(), pci_dev_put() is called to avoid refcount leak.

Fixes 3f12acc8d6d4 ("drm/amdgpu: put the audio codec into suspend state before gpu reset V3")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
index 64510898eedd..69e73fef1ab2 100644
@@ -5027,6 +5027,8 @@ static void amdgpu_device_resume_display_audio(struct amdgpu_device *adev)
 		pm_runtime_enable(&(p->dev));
 		pm_runtime_resume(&(p->dev));
 	}
+
+	pci_dev_put(p);
 }
 
 static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
@@ -5065,6 +5067,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
 
 		if (expires < ktime_get_mono_fast_ns()) {
 			dev_warn(adev->dev, "failed to suspend display audio\n");
+			pci_dev_put(p);
 			/* TODO: abort the succeeding gpu reset? */
 			return -ETIMEDOUT;
 		}
@@ -5072,6 +5075,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
 
 	pm_runtime_disable(&(p->dev));
 
+	pci_dev_put(p);
 	return 0;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Quoted 60 lines

-----Original Message-----
From: Yang Yingliang <[email protected]>
Sent: Thursday, November 17, 2022 11:00 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: fix pci device refcount leak

As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put().

So before returning from amdgpu_device_resume|suspend_display_audio(), pci_dev_put() is called to avoid refcount leak.

Fixes 3f12acc8d6d4 ("drm/amdgpu: put the audio codec into suspend state

before gpu reset V3")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 64510898eedd..69e73fef1ab2 100644
@@ -5027,6 +5027,8 @@ static void
 amdgpu_device_resume_display_audio(struct amdgpu_device *adev)
 		pm_runtime_enable(&(p->dev));
 		pm_runtime_resume(&(p->dev));
 	}
+
+	pci_dev_put(p);
 }
 

static int amdgpu_device_suspend_display_audio(struct amdgpu_device
*adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
@@ -5065,6 +5067,7 @@ static int
 amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
 
 		if (expires < ktime_get_mono_fast_ns()) {
 			dev_warn(adev->dev, "failed to suspend display
 audio\n");
+			pci_dev_put(p);
 			/* TODO: abort the succeeding gpu reset? */
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
 			return -ETIMEDOUT;
 		}
@@ -5072,6 +5075,7 @@ static int
 amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
 
 	pm_runtime_disable(&(p->dev));
 
+	pci_dev_put(p);
 	return 0;
 }
 
--

2.25.1

Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 65 lines · Evan

[AMD Official Use Only - General]

Quoted 60 lines

-----Original Message-----
From: Yang Yingliang <[email protected]>
Sent: Thursday, November 17, 2022 11:00 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; [email protected]
Subject: [PATCH] drm/amdgpu: fix pci device refcount leak

As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put().

So before returning from amdgpu_device_resume|suspend_display_audio(), pci_dev_put() is called to avoid refcount leak.

Fixes 3f12acc8d6d4 ("drm/amdgpu: put the audio codec into suspend state

before gpu reset V3")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 64510898eedd..69e73fef1ab2 100644
@@ -5027,6 +5027,8 @@ static void
 amdgpu_device_resume_display_audio(struct amdgpu_device *adev)
              pm_runtime_enable(&(p->dev));
              pm_runtime_resume(&(p->dev));
      }
+
+     pci_dev_put(p);
 }
 

static int amdgpu_device_suspend_display_audio(struct amdgpu_device
*adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
@@ -5065,6 +5067,7 @@ static int
 amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
 
              if (expires < ktime_get_mono_fast_ns()) {
                      dev_warn(adev->dev, "failed to suspend display
 audio\n");
+                     pci_dev_put(p);
                      /* TODO: abort the succeeding gpu reset? */
                      return -ETIMEDOUT;
              }
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -5072,6 +5075,7 @@ static int
 amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
 
      pm_runtime_disable(&(p->dev));
 
+     pci_dev_put(p);
      return 0;
 }
 
--

2.25.1