diff --git a/drivers/gpu/msm/kgsl_drawobj.c b/drivers/gpu/msm/kgsl_drawobj.c index f5b424a5be04..89f59fcf5342 100755 --- a/drivers/gpu/msm/kgsl_drawobj.c +++ b/drivers/gpu/msm/kgsl_drawobj.c @@ -483,8 +483,12 @@ int kgsl_drawobj_sync_add_sync(struct kgsl_device *device, struct kgsl_drawobj_sync *syncobj, struct kgsl_cmd_syncpoint *sync) { + union { + struct kgsl_cmd_syncpoint_timestamp sync_timestamp; + struct kgsl_cmd_syncpoint_fence sync_fence; + } data; void *priv; - int ret, psize; + int psize; struct kgsl_drawobj *drawobj = DRAWOBJ(syncobj); int (*func)(struct kgsl_device *device, struct kgsl_drawobj_sync *syncobj, @@ -494,10 +498,12 @@ int kgsl_drawobj_sync_add_sync(struct kgsl_device *device, case KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP: psize = sizeof(struct kgsl_cmd_syncpoint_timestamp); func = drawobj_add_sync_timestamp; + priv = &data.sync_timestamp; break; case KGSL_CMD_SYNCPOINT_TYPE_FENCE: psize = sizeof(struct kgsl_cmd_syncpoint_fence); func = drawobj_add_sync_fence; + priv = &data.sync_fence; break; default: KGSL_DRV_ERR(device, @@ -513,19 +519,10 @@ int kgsl_drawobj_sync_add_sync(struct kgsl_device *device, return -EINVAL; } - priv = kzalloc(sync->size, GFP_KERNEL); - if (priv == NULL) - return -ENOMEM; - - if (copy_from_user(priv, sync->priv, sync->size)) { - kfree(priv); + if (copy_from_user(priv, sync->priv, sync->size)) return -EFAULT; - } - ret = func(device, syncobj, priv); - kfree(priv); - - return ret; + return func(device, syncobj, priv); } static void add_profiling_buffer(struct kgsl_device *device,