acpi/pmstat: fix check for empty name strings.
authorTim Deegan <tim@xen.org>
Thu, 12 Sep 2013 12:09:35 +0000 (13:09 +0100)
committerTim Deegan <tim@xen.org>
Thu, 12 Sep 2013 16:48:01 +0000 (17:48 +0100)
These 'name' strings are actually arrays in their structs.  So the
address is never NULL: instead, we should check the first character to
detect cases where the field wasn't initialized.

Coverity CID 1055633

Signed-off-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/acpi/pmstat.c

index f8a9c85eb993e0ada0f7c2ebb379d1f5b7bcdc1e..daac2da57f25dc7d13d1a1222c10629efd79c83f 100644 (file)
@@ -264,13 +264,13 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
     op->u.get_para.scaling_max_freq = policy->max;
     op->u.get_para.scaling_min_freq = policy->min;
 
-    if ( cpufreq_driver->name )
+    if ( cpufreq_driver->name[0] )
         strlcpy(op->u.get_para.scaling_driver, 
             cpufreq_driver->name, CPUFREQ_NAME_LEN);
     else
         strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN);
 
-    if ( policy->governor->name )
+    if ( policy->governor->name[0] )
         strlcpy(op->u.get_para.scaling_governor, 
             policy->governor->name, CPUFREQ_NAME_LEN);
     else