diff options
author | Aurabindo Pillai <aurabindo.pillai@amd.com> | 2020-05-19 16:48:43 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2020-07-15 13:27:34 -0400 |
commit | 6e14adea0ac3037d923a9591d1a094c115d7947c (patch) | |
tree | 2b9977d09070602c2128a073799b0c6dd8425eca /drivers/gpu | |
parent | 91e2c1919230c719c32a3076657f51d4c6074513 (diff) | |
download | linux-6e14adea0ac3037d923a9591d1a094c115d7947c.tar.bz2 |
drm/amd/amdkfd: Fix large framesize for kfd_smi_ev_read()
The buffer allocated is of 1024 bytes. Allocate this from
heap instead of stack.
Also remove check for stack size since we're allocating from heap
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Amber Lin <Amber.Lin@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c index bfc9330df987..7b348bf9df21 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_smi_events.c @@ -78,9 +78,11 @@ static ssize_t kfd_smi_ev_read(struct file *filep, char __user *user, int ret; size_t to_copy; struct kfd_smi_client *client = filep->private_data; - unsigned char buf[MAX_KFIFO_SIZE]; + unsigned char *buf; - BUILD_BUG_ON(MAX_KFIFO_SIZE > 1024); + buf = kmalloc(MAX_KFIFO_SIZE * sizeof(*buf), GFP_KERNEL); + if (!buf) + return -ENOMEM; /* kfifo_to_user can sleep so we can't use spinlock protection around * it. Instead, we kfifo out as spinlocked then copy them to the user. @@ -89,19 +91,29 @@ static ssize_t kfd_smi_ev_read(struct file *filep, char __user *user, to_copy = kfifo_len(&client->fifo); if (!to_copy) { spin_unlock(&client->lock); - return -EAGAIN; + ret = -EAGAIN; + goto ret_err; } to_copy = min3(size, sizeof(buf), to_copy); ret = kfifo_out(&client->fifo, buf, to_copy); spin_unlock(&client->lock); - if (ret <= 0) - return -EAGAIN; + if (ret <= 0) { + ret = -EAGAIN; + goto ret_err; + } ret = copy_to_user(user, buf, to_copy); - if (ret) - return -EFAULT; + if (ret) { + ret = -EFAULT; + goto ret_err; + } + kfree(buf); return to_copy; + +ret_err: + kfree(buf); + return ret; } static ssize_t kfd_smi_ev_write(struct file *filep, const char __user *user, |