Skip to contentSkip to conversation

drm/radeon: fix uninitialized variable

PATCH In review Christian König 2 participants 3 messages Feb 28, 2012 – Feb 29, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: fix uninitialized variable

Without this fix the driver randomly treats
textures as arrays and I'm really wondering
why gcc isn't complaining about it.

---
 drivers/gpu/drm/radeon/r600_cs.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/r600_cs.c +1 -0
index 38ce5d0..387fcc9 100644
@@ -1304,6 +1304,7 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p,  u32 idx,
 	h0 = G_038004_TEX_HEIGHT(word1) + 1;
 	d0 = G_038004_TEX_DEPTH(word1);
 	nfaces = 1;
+	array = 0;
 	switch (G_038000_DIM(word0)) {
 	case V_038000_SQ_TEX_DIM_1D:
 	case V_038000_SQ_TEX_DIM_2D:
Signature · 6 lines
1.7.5.4

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Christian König

Without this fix the driver randomly treats
textures as arrays and I'm really wondering
why gcc isn't complaining about it.

---
 drivers/gpu/drm/radeon/r600_cs.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/r600_cs.c +0 -0
index 38ce5d0..387fcc9 100644

drivers/gpu/drm/radeon/r600_cs.c static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx, · line 1310

Quoted 7 lines
drivers/gpu/drm/radeon/r600_cs.c +1 -0
@@ -1304,6 +1304,7 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p,  u32 idx,
 	h0 = G_038004_TEX_HEIGHT(word1) + 1;
 	d0 = G_038004_TEX_DEPTH(word1);
 	nfaces = 1;
+	array = 0;
 	switch (G_038000_DIM(word0)) {
 	case V_038000_SQ_TEX_DIM_1D:
 	case V_038000_SQ_TEX_DIM_2D:

I think if array field are properly initialized this shouldn't be an issue. But anyway this patch is needed.

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 25 lines · Jerome Glisse
Quoted 14 lines · Christian König

Without this fix the driver randomly treats
textures as arrays and I'm really wondering
why gcc isn't complaining about it.

---
  drivers/gpu/drm/radeon/r600_cs.c |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/r600_cs.c +0 -0
index 38ce5d0..387fcc9 100644

drivers/gpu/drm/radeon/r600_cs.c static int r600_check_texture_resource(struct radeon_cs_parser *p, u32 idx, · line 1310

Quoted 7 lines
drivers/gpu/drm/radeon/r600_cs.c +1 -0
@@ -1304,6 +1304,7 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p,  u32 idx,
  	h0 = G_038004_TEX_HEIGHT(word1) + 1;
  	d0 = G_038004_TEX_DEPTH(word1);
  	nfaces = 1;
+	array = 0;
  	switch (G_038000_DIM(word0)) {
  	case V_038000_SQ_TEX_DIM_1D:
  	case V_038000_SQ_TEX_DIM_2D:

I think if array field are properly initialized this shouldn't be an issue. But anyway this patch is needed.

Quoted 1 line

Yes indeed, and that is also how I stumbled over this bug. It might be problematic for cubemaps, since I don't know how base_array and last_array are initialized there.

Anyway, what concerns me more is why gcc isn't complaining about it? It's quite obvious that the "if" is depending on an uninitialized value here.

Aren't we compiling with "-Wuninitialized" or is it just not work correctly?

Christian.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel