drm/tegra: Fix NULL deref in debugfs/iova
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Mon, 14 Aug 2017 21:53:45 +0000 (23:53 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 17 Aug 2017 15:57:10 +0000 (17:57 +0200)
When IOMMU is off, ->mm_lock is not initialized and ->mm is NULL.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/drm.c

index eddea778290fb3dcb5516824d85368d339fbfb84..86b3e1ce0b659eef3c123f9c6fbbaee32fe4f631 100644 (file)
@@ -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;
 }