Message ID | YmeyEF4djrguNMEF@kili (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] drm/amdgpu: debugfs: fix error codes in write functions | expand |
Applied the series. Thanks! Alex On Tue, Apr 26, 2022 at 4:49 AM Dan Carpenter <dan.carpenter@oracle.com> wrote: > > If the kzalloc() fails then this code will crash. Return -ENOMEM instead. > > Fixes: e50d9ba0d2cd ("drm/amdgpu: Add debugfs TA load/unload/invoke support") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > This would look nicer as: > > shared_buf = memdup_user(&buf[copy_pos], shared_buf_len); > if (IS_ERR(shared_buf)) > return PTR_ERR(shared_buf); > > Probably eventually this will be sent as an automated Coccinelle patch? > > drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c > index 32bcc20b9e3f..6806deb098d3 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c > @@ -254,7 +254,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size > > shared_buf = kzalloc(shared_buf_len, GFP_KERNEL); > if (!shared_buf) > - ret = -ENOMEM; > + return -ENOMEM; > if (copy_from_user((void *)shared_buf, &buf[copy_pos], shared_buf_len)) { > ret = -EFAULT; > goto err_free_shared_buf; > -- > 2.35.1 >
Alex-- On 4/26/22 07:47, Alex Deucher wrote: > Applied the series. Thanks! > > Alex > I just saw a build warning here when CONFIG_DEBUG_FS is not enabled: ../drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c:281:23: warning: 'amdgpu_ta_if_debugfs_create' defined but not used [-Wunused-function] 281 | static struct dentry *amdgpu_ta_if_debugfs_create(struct amdgpu_device *adev) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c index 32bcc20b9e3f..6806deb098d3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c @@ -254,7 +254,7 @@ static ssize_t ta_if_invoke_debugfs_write(struct file *fp, const char *buf, size shared_buf = kzalloc(shared_buf_len, GFP_KERNEL); if (!shared_buf) - ret = -ENOMEM; + return -ENOMEM; if (copy_from_user((void *)shared_buf, &buf[copy_pos], shared_buf_len)) { ret = -EFAULT; goto err_free_shared_buf;
If the kzalloc() fails then this code will crash. Return -ENOMEM instead. Fixes: e50d9ba0d2cd ("drm/amdgpu: Add debugfs TA load/unload/invoke support") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- This would look nicer as: shared_buf = memdup_user(&buf[copy_pos], shared_buf_len); if (IS_ERR(shared_buf)) return PTR_ERR(shared_buf); Probably eventually this will be sent as an automated Coccinelle patch? drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)