Skip to contentSkip to conversation

tgafb: potential NULL dereference in init

PATCH Tomi Valkeinen 1 participant 1 message Jan 10, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 16 lines · Dan Carpenter

Static checkers complain that there are paths where "tga_type_name" can be NULL. I've re-arranged the code slightly so that's impossible.

---
v1: had introduced a "dereferencing uninitialized variable" bug. Thanks to Geert Uytterhoeven for catching that.

drivers/video/tgafb.c +0 -0
index f28674fea909..afd8887fd656 100644
@@ -1496,10 +1496,9 @@ tgafb_init_fix(struct fb_info *info)
 		if (tga_bus_tc)
 			tga_type_name = "Digital ZLX-E3";

drivers/video/tgafb.c tgafb_init_fix(struct fb_info *info) · line 1504

Quoted 10 lines
drivers/video/tgafb.c +2 -3
 		break;
-	default:
-		tga_type_name = "Unknown";
-		break;
 	}
+	if (!tga_type_name)
+		tga_type_name = "Unknown";
 
 	strlcpy(info->fix.id, tga_type_name, sizeof(info->fix.id));
 

Queued for 3.14.

Tomi