[PATCH] drm: Export debugfs functionality for GPL code only

2016-02-07 Thread gr...@linuxhacker.ru
From: Oleg Drokin 

drm_debugfs_create_files and drm_debugfs_remove_files
should only be available for GPL-code only as per Greg-KH

Signed-off-by: Oleg Drokin 
---
 drivers/gpu/drm/drm_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 3bcf8e6..17ae4ae 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -128,7 +128,7 @@ fail:
drm_debugfs_remove_files(files, count, minor);
return ret;
 }
-EXPORT_SYMBOL(drm_debugfs_create_files);
+EXPORT_SYMBOL_GPL(drm_debugfs_create_files);

 /**
  * Initialize the DRI debugfs filesystem for a device
@@ -209,7 +209,7 @@ int drm_debugfs_remove_files(const struct drm_info_list 
*files, int count,
mutex_unlock(&minor->debugfs_lock);
return 0;
 }
-EXPORT_SYMBOL(drm_debugfs_remove_files);
+EXPORT_SYMBOL_GPL(drm_debugfs_remove_files);

 /**
  * Cleanup the debugfs filesystem resources.
-- 
2.1.0



[PATCH 0/2] Fix a couple of dri drivers memory leaks

2015-04-26 Thread gr...@linuxhacker.ru
From: Oleg Drokin 

A couple of memory leaks found by smatch.

Oleg Drokin (2):
  drm/qlx: Fix a memory leak on error path
  drm: fix a memleak on mutex failure path

 drivers/gpu/drm/drm_modeset_lock.c | 4 +++-
 drivers/gpu/drm/qxl/qxl_fb.c   | 7 +--
 2 files changed, 8 insertions(+), 3 deletions(-)

-- 
2.1.0



[PATCH 1/2] drm/qlx: Fix a memory leak on error path

2015-04-26 Thread gr...@linuxhacker.ru
From: Oleg Drokin 

shadow allocation could be leaked if framebuffer allocation failed,
so need to free it.
Also added handling for shadow allocation failure itself instead
of causing a crash.

Found with smatch.

Signed-off-by: Oleg Drokin 
---
 drivers/gpu/drm/qxl/qxl_fb.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index f778c0e..2a88eae 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -526,8 +526,10 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
 mode_cmd.height, mode_cmd.pitches[0]);

shadow = vmalloc(mode_cmd.pitches[0] * mode_cmd.height);
-   /* TODO: what's the usual response to memory allocation errors? */
-   BUG_ON(!shadow);
+   if (!shadow) {
+   ret = -ENOMEM;
+   goto out_unref;
+   }
QXL_INFO(qdev,
"surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n",
 qxl_bo_gpu_offset(qbo),
@@ -538,6 +540,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,

info = framebuffer_alloc(0, device);
if (info == NULL) {
+   vfree(shadow);
ret = -ENOMEM;
goto out_unref;
}
-- 
2.1.0



[PATCH 2/2] drm: fix a memleak on mutex failure path

2015-04-26 Thread gr...@linuxhacker.ru
From: Oleg Drokin 

Need to free just allocated ctx allocation if we cannot
get our config mutex.

This one has been flagged by kbuild bot all the way back in August,
but somehow nobody picked it up:
https://lists.01.org/pipermail/kbuild/2014-August/001691.html

Found with smatch.

Signed-off-by: Oleg Drokin 
CC: Daniel Vetter 
---
 drivers/gpu/drm/drm_modeset_lock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_modeset_lock.c 
b/drivers/gpu/drm/drm_modeset_lock.c
index 51cc47d..1e8c52f 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -80,8 +80,10 @@ int __drm_modeset_lock_all(struct drm_device *dev,
return -ENOMEM;

if (trylock) {
-   if (!mutex_trylock(&config->mutex))
+   if (!mutex_trylock(&config->mutex)) {
+   kfree(ctx);
return -EBUSY;
+   }
} else {
mutex_lock(&config->mutex);
}
-- 
2.1.0



[PATCH v2] drm: fix a memleak on mutex failure path

2015-04-27 Thread gr...@linuxhacker.ru
From: Oleg Drokin 

Need to free just allocated ctx allocation if we cannot
get our config mutex.

This one has been flagged by kbuild bot all the way back in August,
but somehow nobody picked it up:
https://lists.01.org/pipermail/kbuild/2014-August/001691.html

In addition there is another failure path that leaks the same
ctx reference that is fixed.

Found with smatch.

Signed-off-by: Oleg Drokin 
CC: Daniel Vetter 
---
 drivers/gpu/drm/drm_modeset_lock.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_modeset_lock.c 
b/drivers/gpu/drm/drm_modeset_lock.c
index 51cc47d..c0a5cd8 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -80,8 +80,10 @@ int __drm_modeset_lock_all(struct drm_device *dev,
return -ENOMEM;

if (trylock) {
-   if (!mutex_trylock(&config->mutex))
-   return -EBUSY;
+   if (!mutex_trylock(&config->mutex)) {
+   ret = -EBUSY;
+   goto out;
+   }
} else {
mutex_lock(&config->mutex);
}
@@ -114,6 +116,8 @@ fail:
goto retry;
}

+out:
+   kfree(ctx);
return ret;
 }
 EXPORT_SYMBOL(__drm_modeset_lock_all);
-- 
2.1.0