Skip to contentSkip to conversation

sna: move up the assert check before DBG print message

PATCH In review Lim Siew Hoon 2 participants 5 messages Mar 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sna: move up the assert check before DBG print message

The assert check for c->bo should be done before DBG, else it will hit memory access violation when c->bo is null.

---
 src/sna/sna_dri2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/sna/sna_dri2.c +1 -1
index 766ce6d..982bc89 100644
@@ -278,9 +278,9 @@ sna_dri2_get_back(struct sna *sna,
 
 	bo = NULL;
 	list_for_each_entry(c, &priv->cache, link) {
+		assert(c->bo);
 		DBG(("%s: cache: handle=%d, active=%d\n",
 		     __FUNCTION__, c->bo ? c->bo->handle : 0, c->bo ? c->bo->active_scanout : -1));
-		assert(c->bo);
 		if (c->bo->active_scanout == 0) {
 			bo = c->bo;
 			name = c->name;
Signature · 6 lines
2.1.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 6 lines · Lim Siew Hoon

The assert check for c->bo should be done before DBG, else it will hit memory access violation when c->bo is null.

Pardon? With a r-b?
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 9 lines · Lim Siew Hoon
Quoted 5 lines

The assert check for c->bo should be done before DBG, else it will hit memory access violation when c->bo is null.

Pardon? With a r-b?

What is a r-b?
I'm helping to fix the KW issue hit in our repo side.
I suggest the assert checking should be move up before DBG(...) print statement to avoid memory access violation happen if c->bo is NULL for print message. Of cause the chance will be very low to get c->bo is NULL.

...siewhoon

Quoted 4 lines

-Chris

--
Chris Wilson, Intel Open Source Technology Centre

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 11 lines · Siew Hoon
Quoted 9 lines · Lim Siew Hoon
Quoted 5 lines

The assert check for c->bo should be done before DBG, else it will hit memory access violation when c->bo is null.

Pardon? With a r-b?

What is a r-b?

Reviewed-by.

Quoted 1 line

I'm helping to fix the KW issue hit in our repo side.

There is no bug in the code, just kw. It is a ternary operator guarding the dereference.

Quoted 2 lines

I suggest the assert checking should be move up before DBG(...) print statement to avoid memory access violation happen if c->bo is NULL for print message. Of cause the chance will be very low to get c->bo is NULL.

If you look at the code if prints handle=0 if c->bo to indicate the NULL. Please read the code first.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 6 lines · Siew Hoon
Quoted 5 lines
Quoted 5 lines · Lim Siew Hoon
Quoted 3 lines

The assert check for c->bo should be done before DBG, else it will hit memory access violation when c->bo is null.

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Pardon? With a r-b?

What is a r-b?

Reviewed-by.

ohh....sorry about this. It should another 1 lines signed-off-by after Reviewed-by.

Quoted 6 lines
Quoted 2 lines

I'm helping to fix the KW issue hit in our repo side.

There is no bug in the code, just kw. It is a ternary operator guarding the dereference.

Quoted 7 lines
Quoted 1 line

I suggest the assert checking should be move up before DBG(...) print

statement to avoid memory access violation happen if c->bo is NULL for print message.

Quoted 1 line

Of cause the chance will be very low to get c->bo is NULL.

If you look at the code if prints handle=0 if c->bo to indicate the NULL. Please read the code first.

Oh...ok. And you are right. Thank you for feedback.

Quoted 4 lines

-Chris

--
Chris Wilson, Intel Open Source Technology Centre

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx