drm/amdkfd: fix improper return value on error
authorPan Bian <bianpan2016@163.com>
Thu, 1 Dec 2016 08:10:42 +0000 (16:10 +0800)
committerOded Gabbay <oded.gabbay@gmail.com>
Mon, 16 Jan 2017 15:34:47 +0000 (17:34 +0200)
In function kfd_wait_on_events(), when the call to copy_from_user()
fails, the value of return variable ret is 0. 0 indicates success, which
is inconsistent with the execution status. This patch fixes the bug by
assigning "-EFAULT" to ret when copy_from_user() returns an unexpected
value.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/gpu/drm/amd/amdkfd/kfd_events.c

index a6a4b2b..6a3470f 100644 (file)
@@ -739,8 +739,10 @@ int kfd_wait_on_events(struct kfd_process *p,
                struct kfd_event_data event_data;
 
                if (copy_from_user(&event_data, &events[i],
                struct kfd_event_data event_data;
 
                if (copy_from_user(&event_data, &events[i],
-                               sizeof(struct kfd_event_data)))
+                               sizeof(struct kfd_event_data))) {
+                       ret = -EFAULT;
                        goto fail;
                        goto fail;
+               }
 
                ret = init_event_waiter(p, &event_waiters[i],
                                event_data.event_id, i);
 
                ret = init_event_waiter(p, &event_waiters[i],
                                event_data.event_id, i);