diff mbox

drm: tegra: fix NULL deref in debugfs/iova

Message ID 7ca7b47df4aa1c164b7313172564923a2639dcc1.1502747460.git.mirq-linux@rere.qmqm.pl
State Accepted
Headers show

Commit Message

Michał Mirosław Aug. 14, 2017, 9:53 p.m. UTC
When IOMMU is off, ->mm_lock is not initialized and ->mm is NULL.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/gpu/drm/tegra/drm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Thierry Reding Aug. 17, 2017, 3:34 p.m. UTC | #1
On Mon, Aug 14, 2017 at 11:53:45PM +0200, Michał Mirosław wrote:
> When IOMMU is off, ->mm_lock is not initialized and ->mm is NULL.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/gpu/drm/tegra/drm.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

Applied, thanks!

Thierry
diff mbox

Patch

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 8b7842548b9f..f859c06b8ab0 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -1033,9 +1033,11 @@  static int tegra_debugfs_iova(struct seq_file *s, void *data)
 	struct tegra_drm *tegra = drm->dev_private;
 	struct drm_printer p = drm_seq_file_printer(s);
 
-	mutex_lock(&tegra->mm_lock);
-	drm_mm_print(&tegra->mm, &p);
-	mutex_unlock(&tegra->mm_lock);
+	if (tegra->domain) {
+		mutex_lock(&tegra->mm_lock);
+		drm_mm_print(&tegra->mm, &p);
+		mutex_unlock(&tegra->mm_lock);
+	}
 
 	return 0;
 }