From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Aditya Pakki <pakki001@umn.edu>, Ben Skeggs <bskeggs@redhat.com>,
Sasha Levin <sashal@kernel.org>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org
Subject: [PATCH AUTOSEL 4.9 07/17] drm/nouveau: fix multiple instances of reference count leaks
Date: Mon, 10 Aug 2020 15:14:08 -0400 [thread overview]
Message-ID: <20200810191418.3795394-7-sashal@kernel.org> (raw)
In-Reply-To: <20200810191418.3795394-1-sashal@kernel.org>
From: Aditya Pakki <pakki001@umn.edu>
[ Upstream commit 659fb5f154c3434c90a34586f3b7aa1c39cf6062 ]
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>
---
drivers/gpu/drm/nouveau/nouveau_drm.c | 8 ++++++--
drivers/gpu/drm/nouveau/nouveau_gem.c | 4 +++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 42829a942e33c..4e12d3d59651b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -823,8 +823,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
/* need to bring up power immediately if opening device */
ret = pm_runtime_get_sync(dev->dev);
- if (ret < 0 && ret != -EACCES)
+ if (ret < 0 && ret != -EACCES) {
+ pm_runtime_put_autosuspend(dev->dev);
return ret;
+ }
get_task_comm(tmpname, current);
snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
@@ -912,8 +914,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
long ret;
ret = pm_runtime_get_sync(dev->dev);
- if (ret < 0 && ret != -EACCES)
+ if (ret < 0 && ret != -EACCES) {
+ pm_runtime_put_autosuspend(dev->dev);
return ret;
+ }
switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
case DRM_NOUVEAU_NVIF:
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 505dca48b9f80..be6672da33a65 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -42,8 +42,10 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
int ret;
ret = pm_runtime_get_sync(dev);
- if (WARN_ON(ret < 0 && ret != -EACCES))
+ if (WARN_ON(ret < 0 && ret != -EACCES)) {
+ pm_runtime_put_autosuspend(dev);
return;
+ }
if (gem->import_attach)
drm_prime_gem_destroy(gem, nvbo->bo.sg);
--
2.25.1
next prev parent reply other threads:[~2020-08-10 19:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 19:14 [PATCH AUTOSEL 4.9 01/17] drm/tilcdc: fix leak & null ref in panel_connector_get_modes Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 02/17] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 03/17] fs/btrfs: Add cond_resched() for try_release_extent_mapping() stalls Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 04/17] drm/radeon: Fix reference count leaks caused by pm_runtime_get_sync Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 05/17] video: fbdev: neofb: fix memory leak in neo_scan_monitor() Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 06/17] md-cluster: fix wild pointer of unlock_all_bitmaps() Sasha Levin
2020-08-10 19:14 ` Sasha Levin [this message]
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 08/17] drm/debugfs: fix plain echo to connector "force" attribute Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 09/17] mm/mmap.c: Add cond_resched() for exit_mmap() CPU stalls Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 10/17] brcmfmac: To fix Bss Info flag definition Bug Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 11/17] iwlegacy: Check the return value of pcie_capability_read_*() Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 12/17] usb: gadget: net2280: fix memory leak on probe error handling paths Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 13/17] bdc: Fix bug causing crash after multiple disconnects Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 14/17] dyndbg: fix a BUG_ON in ddebug_describe_flags Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 15/17] dyndbg: prefer declarative init in caller, to memset in callee Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 16/17] bcache: fix super block seq numbers comparision in register_cache_set() Sasha Levin
2020-08-10 19:14 ` [PATCH AUTOSEL 4.9 17/17] ACPICA: Do not increment operation_region reference counts for field units Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200810191418.3795394-7-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=pakki001@umn.edu \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®