Skip to contentSkip to conversation

XEN: Make handle_vcpu_hotplug_event() to check the sscanf() return value

PATCH In review [email protected] 2 participants 2 messages Mar 12, 2010 – Mar 13, 2010 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 XEN: Make handle_vcpu_hotplug_event() to check the sscanf() return value

It seems handle_vcpu_hotplug_event() not check the sscanf() return value.

---
 drivers/xen/cpu_hotplug.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/xen/cpu_hotplug.c +2 -2
index 14e2d99..99773a6 100644
@@ -69,8 +69,8 @@ static void handle_vcpu_hotplug_event(struct xenbus_watch *watch,
 
 	cpustr = strstr(node, "cpu/");
 	if (cpustr != NULL) {
-		sscanf(cpustr, "cpu/%u", &cpu);
-		vcpu_hotplug(cpu);
+		if (sscanf(cpustr, "cpu/%u", &cpu) == 1)
+			vcpu_hotplug(cpu);
 	}
 }
 
Signature · 1 line
1.6.5.3
#1 lore raw
Quoted 4 lines · On 03/11/2010 06:53 PM, [email protected] wrote:

It seems handle_vcpu_hotplug_event() not check the sscanf() return value.

Good catch, thanks.

J

Quoted 20 lines
---
  drivers/xen/cpu_hotplug.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
drivers/xen/cpu_hotplug.c +2 -2
index 14e2d99..99773a6 100644
@@ -69,8 +69,8 @@ static void handle_vcpu_hotplug_event(struct xenbus_watch *watch,
 
  	cpustr = strstr(node, "cpu/");
  	if (cpustr != NULL) {
-		sscanf(cpustr, "cpu/%u",&cpu);
-		vcpu_hotplug(cpu);
+		if (sscanf(cpustr, "cpu/%u",&cpu) == 1)
+			vcpu_hotplug(cpu);
  	}
  }