Message ID | b9adf038b3ccf058c49e7e74e1998bc2216e0678.1744468610.git.dan.carpenter@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | drm/amdgpu: Fixes to amdgpu_userq_fence_driver_alloc() | expand |
Reviewed-by:Arvind Yadav <arvind.yadav@amd.com> On 4/12/2025 8:09 PM, Dan Carpenter wrote: > 1) Checkpatch complains if we print an error message for kzalloc() > failure. The kzalloc() failure already has it's own error messages > built in. Also this allocation is small enough that it is guaranteed > to succeed. > 2) Return directly instead of doing a goto free_fence_drv. The > "fence_drv" is already NULL so no cleanup is necessary. > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> > --- > v2: New patch > > drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c > index b012fece91e8..86eab5461162 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c > @@ -75,11 +75,8 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device *adev, > int r; > > fence_drv = kzalloc(sizeof(*fence_drv), GFP_KERNEL); > - if (!fence_drv) { > - DRM_ERROR("Failed to allocate memory for fence driver\n"); > - r = -ENOMEM; > - goto free_fence_drv; > - } > + if (!fence_drv) > + return -ENOMEM; > > /* Acquire seq64 memory */ > r = amdgpu_seq64_alloc(adev, &fence_drv->va, &fence_drv->gpu_addr,
Applied the series. Thanks! On Mon, Apr 14, 2025 at 12:48 AM Yadav, Arvind <arvyadav@amd.com> wrote: > > Reviewed-by:Arvind Yadav <arvind.yadav@amd.com> > > On 4/12/2025 8:09 PM, Dan Carpenter wrote: > > 1) Checkpatch complains if we print an error message for kzalloc() > > failure. The kzalloc() failure already has it's own error messages > > built in. Also this allocation is small enough that it is guaranteed > > to succeed. > > 2) Return directly instead of doing a goto free_fence_drv. The > > "fence_drv" is already NULL so no cleanup is necessary. > > > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> > > --- > > v2: New patch > > > > drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 7 ++----- > > 1 file changed, 2 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c > > index b012fece91e8..86eab5461162 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c > > @@ -75,11 +75,8 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device *adev, > > int r; > > > > fence_drv = kzalloc(sizeof(*fence_drv), GFP_KERNEL); > > - if (!fence_drv) { > > - DRM_ERROR("Failed to allocate memory for fence driver\n"); > > - r = -ENOMEM; > > - goto free_fence_drv; > > - } > > + if (!fence_drv) > > + return -ENOMEM; > > > > /* Acquire seq64 memory */ > > r = amdgpu_seq64_alloc(adev, &fence_drv->va, &fence_drv->gpu_addr,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c index b012fece91e8..86eab5461162 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c @@ -75,11 +75,8 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device *adev, int r; fence_drv = kzalloc(sizeof(*fence_drv), GFP_KERNEL); - if (!fence_drv) { - DRM_ERROR("Failed to allocate memory for fence driver\n"); - r = -ENOMEM; - goto free_fence_drv; - } + if (!fence_drv) + return -ENOMEM; /* Acquire seq64 memory */ r = amdgpu_seq64_alloc(adev, &fence_drv->va, &fence_drv->gpu_addr,
1) Checkpatch complains if we print an error message for kzalloc() failure. The kzalloc() failure already has it's own error messages built in. Also this allocation is small enough that it is guaranteed to succeed. 2) Return directly instead of doing a goto free_fence_drv. The "fence_drv" is already NULL so no cleanup is necessary. Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> --- v2: New patch drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)