All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 21/22] dma-buf/reservation: shouldn't kfree staged when slot available
@ 2018-02-26  5:34 Monk Liu
       [not found] ` <1519623300-17305-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 18+ messages in thread
From: Monk Liu @ 2018-02-26  5:34 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Monk Liu

issue:
kernel oops or vmc page fault occured during vk_example/vk_cts
test.

root cause:
previously reservation object would kfree the staged when slot
checked available during reserve_shared(), which is incorrect
becasue this way reservation_object->fence will be a wild pointer
referenced by following reservation_object_add_shared_fence,
and lead to lot of abnormal cases depends on luck.

fix:
don't call kfree on staged in reserve_shared
and there won't be memleak introduced because reservation's
finish routine would kfree both staged and fence

Change-Id: If7c01f1b4be3d3d8a81efa90216841f79ab1fc1c
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 drivers/dma-buf/reservation.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index 314eb10..bc01e0d 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -74,12 +74,9 @@ int reservation_object_reserve_shared(struct reservation_object *obj)
 	old = reservation_object_get_list(obj);
 
 	if (old && old->shared_max) {
-		if (old->shared_count < old->shared_max) {
-			/* perform an in-place update */
-			kfree(obj->staged);
-			obj->staged = NULL;
+		if (old->shared_count < old->shared_max)
 			return 0;
-		} else
+		else
 			max = old->shared_max * 2;
 	} else
 		max = 4;
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2018-02-28 13:01 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26  5:34 [PATCH 21/22] dma-buf/reservation: shouldn't kfree staged when slot available Monk Liu
     [not found] ` <1519623300-17305-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26  5:35   ` [PATCH 22/22] drm/amdgpu: fix reservation obj shared count bug Monk Liu
     [not found]     ` <1519623300-17305-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26  9:47       ` Christian König
     [not found]         ` <f3854579-e1dc-1226-9807-3e67a1a9bb7c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-02-26 10:32           ` Liu, Monk
2018-02-26 10:36           ` Liu, Monk
     [not found]             ` <SN1PR12MB0462FDC9905B318AF45FCECC84C10-z7L1TMIYDg7VaWpRXmIMygdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-26 10:44               ` Christian König
     [not found]                 ` <7b2c1408-8ffc-4b8a-94e4-45534dff99f8-5C7GfCeVMHo@public.gmane.org>
2018-02-26 10:54                   ` Chris Wilson
2018-02-26 10:57                   ` Liu, Monk
     [not found]                     ` <SN1PR12MB0462022ABFBC835ACE0D34E484C10-z7L1TMIYDg7VaWpRXmIMygdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-26 11:18                       ` Christian König
     [not found]                         ` <0a041a5c-9d7f-e307-7730-275ba7b775c9-5C7GfCeVMHo@public.gmane.org>
2018-02-27  3:36                           ` Liu, Monk
     [not found]                             ` <BLUPR12MB0449672DB665AD8DB6E081BD84C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-27  8:34                               ` Christian König
     [not found]                                 ` <b0d669c0-e6e8-5907-a33c-3b94890fd091-5C7GfCeVMHo@public.gmane.org>
2018-02-27  9:17                                   ` Liu, Monk
     [not found]                                     ` <BLUPR12MB0449422688494CE8CE97647884C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-28 12:38                                       ` Christian König
     [not found]                                         ` <889bf3af-4fa5-def3-a3c3-410fdd0ccd3e-5C7GfCeVMHo@public.gmane.org>
2018-02-28 13:01                                           ` Liu, Monk
2018-02-26  9:42   ` [PATCH 21/22] dma-buf/reservation: shouldn't kfree staged when slot available Christian König
     [not found]     ` <afa20c31-f721-599e-7e4c-eecbf7bda70f-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-02-26 10:13       ` Liu, Monk
2018-02-26 10:19       ` Chris Wilson
     [not found]         ` <151964034205.2350.2554778746105246165-M6iVdVfohj6unts5RBS2dVaTQe2KTcn/@public.gmane.org>
2018-02-26 10:25           ` Liu, Monk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.