Skip to content

Commit afd847b

Browse files
Aditya Pakkigregkh
authored andcommitted
drm/nouveau: fix multiple instances of reference count leaks
[ Upstream commit 659fb5f ] On calling pm_runtime_get_sync() the reference count of the device is incremented. In case of failure, decrement the ref count before returning the error. Signed-off-by: Aditya Pakki <pakki001@umn.edu> Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3d6955b commit afd847b

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/gpu/drm/nouveau/nouveau_drm.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
899899

900900
/* need to bring up power immediately if opening device */
901901
ret = pm_runtime_get_sync(dev->dev);
902-
if (ret < 0 && ret != -EACCES)
902+
if (ret < 0 && ret != -EACCES) {
903+
pm_runtime_put_autosuspend(dev->dev);
903904
return ret;
905+
}
904906

905907
get_task_comm(tmpname, current);
906908
snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
@@ -980,8 +982,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
980982
long ret;
981983

982984
ret = pm_runtime_get_sync(dev->dev);
983-
if (ret < 0 && ret != -EACCES)
985+
if (ret < 0 && ret != -EACCES) {
986+
pm_runtime_put_autosuspend(dev->dev);
984987
return ret;
988+
}
985989

986990
switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
987991
case DRM_NOUVEAU_NVIF:

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
4646
int ret;
4747

4848
ret = pm_runtime_get_sync(dev);
49-
if (WARN_ON(ret < 0 && ret != -EACCES))
49+
if (WARN_ON(ret < 0 && ret != -EACCES)) {
50+
pm_runtime_put_autosuspend(dev);
5051
return;
52+
}
5153

5254
if (gem->import_attach)
5355
drm_prime_gem_destroy(gem, nvbo->bo.sg);

0 commit comments

Comments
 (0)