linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Delete an unnecessary check before two function calls
@ 2019-09-04 11:00 Markus Elfring
  2019-09-04 17:11 ` Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2019-09-04 11:00 UTC (permalink / raw)
  To: amd-gfx, dri-devel, Alex Deucher, Christian König,
	Chunming Zhou, Dan Carpenter, Daniel Vetter, David Airlie,
	Hawking Zhang, Jack Xiao, Kevin Wang, Tom St Denis, Wang Xiayang
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Sep 2019 12:30:23 +0200

The functions “debugfs_remove” and “kfree” test whether their argument
is NULL and then return immediately.
Thus the tests around the shown calls are not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 5652cc72ed3a..d321c72d63d1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -1076,10 +1076,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)
 	kthread_unpark(ring->sched.thread);

 	ttm_bo_unlock_delayed_workqueue(&adev->mman.bdev, resched);
-
-	if (fences)
-		kfree(fences);
-
+	kfree(fences);
 	return 0;
 }

@@ -1103,8 +1100,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)

 void amdgpu_debugfs_preempt_cleanup(struct amdgpu_device *adev)
 {
-	if (adev->debugfs_preempt)
-		debugfs_remove(adev->debugfs_preempt);
+	debugfs_remove(adev->debugfs_preempt);
 }

 #else
--
2.23.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: drm/amdgpu: Delete an unnecessary check before two function calls
  2019-09-04 11:00 [PATCH] drm/amdgpu: Delete an unnecessary check before two function calls Markus Elfring
@ 2019-09-04 17:11 ` Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2019-09-04 17:11 UTC (permalink / raw)
  To: amd-gfx, dri-devel, Alex Deucher, Christian König,
	Chunming Zhou, Dan Carpenter, Daniel Vetter, David Airlie,
	Hawking Zhang, Jack Xiao, Kevin Wang, Tom St Denis, Wang Xiayang
  Cc: LKML, kernel-janitors

> The functions “debugfs_remove” and “kfree” test whether their argument
> is NULL and then return immediately.
> Thus the tests around the shown calls are not needed.
>
> This issue was detected by using the Coccinelle software.

I suggest to take another look at a similar patch.

drm/amdgpu: remove the redundant null check
https://lkml.org/lkml/2019/9/3/59
https://lore.kernel.org/patchwork/patch/1123118/
https://lore.kernel.org/r/1567491305-18320-1-git-send-email-zhongjiang@huawei.com/

Regards,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-04 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04 11:00 [PATCH] drm/amdgpu: Delete an unnecessary check before two function calls Markus Elfring
2019-09-04 17:11 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).