summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorSharat Masetty <smasetty@codeaurora.org>2017-06-13 12:37:05 +0530
committerSharat Masetty <smasetty@codeaurora.org>2017-06-16 15:59:47 +0530
commitb0f487c506d21033d1f0421003f98dbf3cb79bbc (patch)
treec4c9d2caa24795d2182bd496e40067eb262a8311 /drivers/gpu
parentc1a2472056c800ff46e0ac21a4b67c179a570ad0 (diff)
drm/msm: gracefully handle NULL return from setup_pagetable()
There is a possibility that load_gpu() can fail to initialize and turn on the GPU successfully due to system level issues such as a clock or a regulator not turning on. In such a case setup_pagetable() returns a NULL pointer which is not handled correctly in msm_open(). This leads to a crash in INIT_LIST_HEAD() which tries to access a NULL pointer. This patch properly handles the NULL return and initializes the list head only if the gpu load was successful, also adds missing NULL checks to places in the code where the msm_file_private structure was being accessed. Change-Id: I6eb85227d928a82c3cf2553fd6645affdd986473 Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c3
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c6
-rw-r--r--drivers/gpu/drm/msm/msm_gem_submit.c2
-rw-r--r--drivers/gpu/drm/msm/msm_gpu.c3
4 files changed, 11 insertions, 3 deletions
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index a3bdc30b9620..d1d618d3ff92 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -602,7 +602,8 @@ static int msm_open(struct drm_device *dev, struct drm_file *file)
if (IS_ERR(ctx))
return PTR_ERR(ctx);
- INIT_LIST_HEAD(&ctx->counters);
+ if (ctx)
+ INIT_LIST_HEAD(&ctx->counters);
file->driver_priv = ctx;
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 6bb29c62378d..0b3de2cb4179 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -1038,7 +1038,7 @@ struct drm_gem_object *msm_gem_svm_new(struct drm_device *dev,
{
struct drm_gem_object *obj;
struct msm_file_private *ctx = file->driver_priv;
- struct msm_gem_address_space *aspace = ctx->aspace;
+ struct msm_gem_address_space *aspace;
struct msm_gem_object *msm_obj;
struct msm_gem_svm_object *msm_svm_obj;
struct msm_gem_vma *domain = NULL;
@@ -1048,6 +1048,9 @@ struct drm_gem_object *msm_gem_svm_new(struct drm_device *dev,
int write;
int ret;
+ if (!ctx)
+ return ERR_PTR(-ENODEV);
+
/* if we don't have IOMMU, don't bother pretending we can import: */
if (!iommu_present(&platform_bus_type)) {
dev_err_once(dev->dev, "cannot import without IOMMU\n");
@@ -1070,6 +1073,7 @@ struct drm_gem_object *msm_gem_svm_new(struct drm_device *dev,
drm_gem_private_object_init(dev, obj, size);
msm_obj = to_msm_bo(obj);
+ aspace = ctx->aspace;
domain = obj_add_domain(&msm_obj->base, aspace);
if (IS_ERR(domain)) {
drm_gem_object_unreference_unlocked(obj);
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index c861bfd77537..c9802fea6878 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -409,7 +409,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
return -EINVAL;
gpu = priv->gpu;
- if (!gpu)
+ if (!gpu || !ctx)
return -ENXIO;
mutex_lock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 81bab9cc22af..4fd76e9e11f9 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -652,6 +652,9 @@ int msm_gpu_counter_put(struct msm_gpu *gpu, struct drm_msm_counter *data,
{
struct msm_context_counter *entry;
+ if (!gpu || !ctx)
+ return -ENODEV;
+
list_for_each_entry(entry, &ctx->counters, node) {
if (entry->groupid == data->groupid &&
entry->counterid == data->counterid) {