From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: [PATCH 9/9] acpi/pmstat: fix check for empty name strings. Date: Thu, 12 Sep 2013 13:15:30 +0100 Message-ID: <1378988130-24172-10-git-send-email-tim@xen.org> References: <1378988130-24172-1-git-send-email-tim@xen.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1378988130-24172-1-git-send-email-tim@xen.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Jan Beulich List-Id: xen-devel@lists.xenproject.org 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 Cc: Jan Beulich --- xen/drivers/acpi/pmstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index f8a9c85..daac2da 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -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 -- 1.7.10.4