Skip to contentSkip to conversation

intel_ips: potential null dereference

PATCH In review Dan Carpenter 2 participants 2 messages Aug 7, 2010

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

PATCH 1/1 intel_ips: potential null dereference

There is a potential NULL dereference of "limits." We can just return NULL earlier to avoid it. The caller already handles NULL returns.

drivers/platform/x86/intel_ips.c +3 -1
index afe82e5..c908048 100644
@@ -1342,8 +1342,10 @@ static struct ips_mcp_limits *ips_detect_cpu(struct ips_driver *ips)
 		limits = &ips_lv_limits;
 	else if (strstr(boot_cpu_data.x86_model_id, "CPU       U"))
 		limits = &ips_ulv_limits;
-	else
+	else {
 		dev_info(&ips->dev->dev, "No CPUID match found.\n");
+		goto out;
+	}
 
 	rdmsrl(TURBO_POWER_CURRENT_LIMIT, turbo_power);
 	tdp = turbo_power & TURBO_TDP_MASK;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Sun, 8 Aug 2010 00:01:12 +0200 Dan Carpenter <[email protected]> wrote:

There is a potential NULL dereference of "limits." We can just return NULL earlier to avoid it. The caller already handles NULL returns.

drivers/platform/x86/intel_ips.c +0 -0
index afe82e5..c908048 100644
@@ -1342,8 +1342,10 @@ static struct ips_mcp_limits *ips_detect_cpu(struct ips_driver *ips)
 		limits = &ips_lv_limits;

drivers/platform/x86/intel_ips.c static struct ips_mcp_limits *ips_detect_cpu(struct ips_driver *ips) · line 1351

Quoted 10 lines
drivers/platform/x86/intel_ips.c +3 -1
 	else if (strstr(boot_cpu_data.x86_model_id, "CPU       U"))
 		limits = &ips_ulv_limits;
-	else
+	else {
 		dev_info(&ips->dev->dev, "No CPUID match found.\n");
+		goto out;
+	}
 
 	rdmsrl(TURBO_POWER_CURRENT_LIMIT, turbo_power);
 	tdp = turbo_power & TURBO_TDP_MASK;

Yep, good idea to catch this case.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center