Skip to contentSkip to conversation

More Coverity-reported issues.

PATCH In review Tim Deegan 5 participants 24 messages Sep 12, 2013 – Sep 17, 2013

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

Another bundle of issues from Coverity triage.
The first one is in x86/mm, and looks scarier than it is. The others are all in xen/drivers and AFAICT are pretty minor.

Cheers,

Tim.

author
#1 lore raw

PATCH 1/9 x86/mm: Don't dereference p2m pointer before NULL check.

Not a security bug, because in fact this is never called with a NULL argument.

Coverity CID 1055955

---
 xen/arch/x86/mm/p2m.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/mm/p2m.c +3 -1
index f5ddd20..8f380ed 100644
@@ -453,7 +453,7 @@ void p2m_teardown(struct p2m_domain *p2m)
  * We know we don't have any extra mappings to these pages */
 {
     struct page_info *pg;
-    struct domain *d = p2m->domain;
+    struct domain *d;
     unsigned long gfn;
     p2m_type_t t;
     mfn_t mfn;
@@ -461,6 +461,8 @@ void p2m_teardown(struct p2m_domain *p2m)
     if (p2m == NULL)
         return;
 
+    d = p2m->domain;
+
     p2m_lock(p2m);
 
     /* Try to unshare any remaining shared p2m entries. Safeguard
Signature · 1 line
1.7.10.4
author
#2 lore raw

PATCH 2/9 passthrough/amd: Drop unnecessary lock lookup.

In reply to Tim Deegan

The lock's not used for anything, and AFAICT no locking is needed since the IVRS tables are static after boot.

Coverity CID 1087199

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
 xen/drivers/passthrough/amd/iommu_intr.c |    1 -
 1 file changed, 1 deletion(-)
xen/drivers/passthrough/amd/iommu_intr.c +0 -1
index 831f92a..213f4d7 100644
@@ -443,7 +443,6 @@ static int update_intremap_entry_from_msi_msg(
      * devices.
      */
 
-    lock = get_intremap_lock(iommu->seg, alias_id);
     if ( ( req_id != alias_id ) &&
          get_ivrs_mappings(iommu->seg)[alias_id].intremap_table != NULL )
     {
Signature · 1 line
1.7.10.4
Reviewed-by on v1 2/9
#3 lore raw

Re: [PATCH 2/9] passthrough/amd: Drop unnecessary lock lookup.

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

The lock's not used for anything, and AFAICT no locking is needed since the IVRS tables are static after boot.

Coverity CID 1087199

That was an oversight of mine I think.

Quoted 18 lines
xen/drivers/passthrough/amd/iommu_intr.c +0 -1
@@ -443,7 +443,6 @@ static int update_intremap_entry_from_msi_msg(
      * devices.
      */
 
-    lock = get_intremap_lock(iommu->seg, alias_id);
     if ( ( req_id != alias_id ) &&
          get_ivrs_mappings(iommu->seg)[alias_id].intremap_table != NULL )
     {
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected] 
http://lists.xen.org/xen-devel 
author
#4 lore raw

PATCH 3/9 passthrough/amd: Missing 'break'

In reply to Tim Deegan

Coverity CID 1055502

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
 xen/drivers/passthrough/amd/iommu_guest.c |    1 +
 1 file changed, 1 insertion(+)
xen/drivers/passthrough/amd/iommu_guest.c +1 -0
index 85f2361..952600a 100644
@@ -728,6 +728,7 @@ static void guest_iommu_mmio_write64(struct guest_iommu *iommu,
         break;
     case IOMMU_EVENT_LOG_BASE_LOW_OFFSET:
         u64_to_reg(&iommu->event_log.reg_base, val);
+        break;
     case IOMMU_PPR_LOG_BASE_LOW_OFFSET:
         u64_to_reg(&iommu->ppr_log.reg_base, val);
         break;
Signature · 1 line
1.7.10.4
Acked-by on v1 3/9
#5 lore raw

Re: [PATCH 3/9] passthrough/amd: Missing 'break'

Quoted 14 lines · Tim Deegan

Coverity CID 1055502

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
  xen/drivers/passthrough/amd/iommu_guest.c |    1 +
  1 file changed, 1 insertion(+)
xen/drivers/passthrough/amd/iommu_guest.c +0 -0
index 85f2361..952600a 100644

xen/drivers/passthrough/amd/iommu_guest.c static void guest_iommu_mmio_write64(struct guest_iommu *iommu, · line 734

Quoted 7 lines
xen/drivers/passthrough/amd/iommu_guest.c +1 -0
@@ -728,6 +728,7 @@ static void guest_iommu_mmio_write64(struct guest_iommu *iommu,
          break;
      case IOMMU_EVENT_LOG_BASE_LOW_OFFSET:
          u64_to_reg(&iommu->event_log.reg_base, val);
+        break;
      case IOMMU_PPR_LOG_BASE_LOW_OFFSET:
          u64_to_reg(&iommu->ppr_log.reg_base, val);
          break;
author
#6 lore raw

PATCH 4/9 passthrough/amd: Shuffle declaration.

In reply to Tim Deegan

Coverity's parser chokes on seeing __section() before the type.

Coverity CID 1087190

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
 xen/drivers/passthrough/amd/iommu_acpi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
index 89b359c..2bfe61e 100644
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
     return dev_length;
 }
 
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(__initdata ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
 
 static void __init parse_ivrs_ioapic(char *str)
 {
Signature · 1 line
1.7.10.4
#7 lore raw

Re: [PATCH 4/9] passthrough/amd: Shuffle declaration.

Quoted 18 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

Coverity's parser chokes on seeing __section() before the type.

Coverity CID 1087190

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
 xen/drivers/passthrough/amd/iommu_acpi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/amd/iommu_acpi.c +0 -0
index 89b359c..2bfe61e 100644

xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_extended_range( · line 636

Quoted 5 lines
xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
     return dev_length;
 }
 
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(__initdata ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));

But putting it inside the DECLARE_BITMAP() doesn't seem that nice either. I think the second best option - if we need to play such games for Coverity in the first place - would be to put this at the end.

Jan

author
#8 lore raw

Re: [PATCH 4/9] passthrough/amd: Shuffle declaration.

Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

Coverity's parser chokes on seeing __section() before the type.

Coverity CID 1087190

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
 xen/drivers/passthrough/amd/iommu_acpi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/amd/iommu_acpi.c +0 -0
index 89b359c..2bfe61e 100644
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
     return dev_length;
 }
 
Quoted 6 lines

xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_extended_range( · line 636

Quoted 2 lines
xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(__initdata ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));

But putting it inside the DECLARE_BITMAP() doesn't seem that nice either. I think the second best option - if we need to play such games for Coverity in the first place -

Yes, I think the question of how much we're willing to accommodate Coverity in our source code needs to be discussed. On that subject I have an RFC patch that introduces some annotation...

Quoted 1 line

would be to put this at the end.

Yes, that sounds better. Thus?

index 89b359c..e967eba 100644

xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
     return dev_length;
 }
 
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf)) __initdata;
 
 static void __init parse_ivrs_ioapic(char *str)
 {

Tim.

#9 lore raw

Re: [PATCH 4/9] passthrough/amd: Shuffle declaration.

Quoted 30 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

Coverity's parser chokes on seeing __section() before the type.

Coverity CID 1087190

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
 xen/drivers/passthrough/amd/iommu_acpi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/amd/iommu_acpi.c +0 -0
index 89b359c..2bfe61e 100644
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
     return dev_length;
 }
 
Quoted 6 lines

xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_extended_range( · line 636

Quoted 2 lines
xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(__initdata ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));

But putting it inside the DECLARE_BITMAP() doesn't seem that nice either. I think the second best option - if we need to play such games for Coverity in the first place -

Quoted 7 lines

Yes, I think the question of how much we're willing to accommodate Coverity in our source code needs to be discussed. On that subject I have an RFC patch that introduces some annotation...

Quoted 1 line

would be to put this at the end.

Yes, that sounds better. Thus?

Ack.

Quoted 13 lines
xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
     return dev_length;
 }
 
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf)) __initdata;
 
 static void __init parse_ivrs_ioapic(char *str)
 {

Tim.

#10 lore raw

Re: [PATCH 4/9] passthrough/amd: Shuffle declaration.

Quoted 42 lines · Jan Beulich
Quoted 28 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 21 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

Coverity's parser chokes on seeing __section() before the type.

Coverity CID 1087190

Cc Suravee Suthikulpanit <[email protected]>
Cc Jacob Shin <[email protected]>
---
  xen/drivers/passthrough/amd/iommu_acpi.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/amd/iommu_acpi.c +0 -0
index 89b359c..2bfe61e 100644
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
      return dev_length;
  }
 
Quoted 5 lines

xen/drivers/passthrough/amd/iommu_acpi.c static u16 __init parse_ivhd_device_extended_range( · line 636

Quoted 2 lines
xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(__initdata ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));

But putting it inside the DECLARE_BITMAP() doesn't seem that nice either. I think the second best option - if we need to play such games for Coverity in the first place -

Quoted 6 lines

Yes, I think the question of how much we're willing to accommodate Coverity in our source code needs to be discussed. On that subject I have an RFC patch that introduces some annotation...

Quoted 1 line

would be to put this at the end.

Yes, that sounds better. Thus?

Ack.

Quoted 6 lines
xen/drivers/passthrough/amd/iommu_acpi.c +0 -0
@@ -633,7 +633,7 @@ static u16 __init parse_ivhd_device_extended_range(
      return dev_length;
  }
 
Quoted 7 lines
Quoted 7 lines
xen/drivers/passthrough/amd/iommu_acpi.c +1 -1
-static __initdata DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf));
+static DECLARE_BITMAP(ioapic_cmdline, ARRAY_SIZE(ioapic_sbdf)) __initdata;
 
  static void __init parse_ivrs_ioapic(char *str)
  {

Tim.

author
#11 lore raw

PATCH 5/9 cpufreq: avoid integer overflows.

In reply to Tim Deegan

The def_sampling_rate() one is, I think, a real bug. The others were spotted at the same time and are probably not bugs until we start dealing with 40GHz CPus.

Coverity CID 1055682
Coverity CID 1055683

Cc Jan Beulich <[email protected]>
Cc Liu Jinsong <[email protected]>
---
 xen/drivers/cpufreq/cpufreq_ondemand.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
xen/drivers/cpufreq/cpufreq_ondemand.c +4 -3
index b3f9ab8..7fdba03 100644
@@ -144,7 +144,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
     }
 
     /* Check for frequency increase */
-    if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
+    if (max_load_freq > (uint64_t) dbs_tuners_ins.up_threshold * policy->cur) {
         /* if we are already at full speed then break out early */
         if (policy->cur == max)
             return;
@@ -162,7 +162,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
      * can support the current CPU usage without triggering the up
      * policy. To be safe, we focus 10 points under the threshold.
      */
-    if (max_load_freq < (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
+    if (max_load_freq
+        < (uint64_t) (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
         uint64_t freq_next;
 
         freq_next = max_load_freq / (dbs_tuners_ins.up_threshold - 10);
@@ -246,7 +247,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event)
          * is used for first time
          */
         if ((dbs_enable == 1) && !dbs_tuners_ins.sampling_rate) {
-            def_sampling_rate = policy->cpuinfo.transition_latency *
+            def_sampling_rate = (uint64_t) policy->cpuinfo.transition_latency *
                 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
 
             if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
Signature · 1 line
1.7.10.4
Acked-by on v1 5/9
#12 lore raw

Re: [PATCH 5/9] cpufreq: avoid integer overflows.

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

The def_sampling_rate() one is, I think, a real bug. The others were spotted at the same time and are probably not bugs until we start dealing with 40GHz CPus.

Coverity CID 1055682
Coverity CID 1055683

Quoted 45 lines
Cc Liu Jinsong <[email protected]>
---
 xen/drivers/cpufreq/cpufreq_ondemand.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
xen/drivers/cpufreq/cpufreq_ondemand.c +1 -1
index b3f9ab8..7fdba03 100644
@@ -144,7 +144,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s 
 *this_dbs_info)
     }
 
     /* Check for frequency increase */
-    if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
+    if (max_load_freq > (uint64_t) dbs_tuners_ins.up_threshold * policy->cur) 
 {
         /* if we are already at full speed then break out early */
         if (policy->cur == max)
             return;
xen/drivers/cpufreq/cpufreq_ondemand.c +2 -1
@@ -162,7 +162,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s 
 *this_dbs_info)
      * can support the current CPU usage without triggering the up
      * policy. To be safe, we focus 10 points under the threshold.
      */
-    if (max_load_freq < (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
+    if (max_load_freq
+        < (uint64_t) (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
         uint64_t freq_next;
 
         freq_next = max_load_freq / (dbs_tuners_ins.up_threshold - 10);
xen/drivers/cpufreq/cpufreq_ondemand.c +1 -1
@@ -246,7 +247,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, 
 unsigned int event)
          * is used for first time
          */
         if ((dbs_enable == 1) && !dbs_tuners_ins.sampling_rate) {
-            def_sampling_rate = policy->cpuinfo.transition_latency *
+            def_sampling_rate = (uint64_t) policy->cpuinfo.transition_latency 
 *
                 DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;

if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)

Signature · 1 line
1.7.10.4
Acked-by on v1 5/9
#13 lore raw

Re: [PATCH 5/9] cpufreq: avoid integer overflows.

In reply to Tim Deegan
Quoted 48 lines · Tim Deegan

The def_sampling_rate() one is, I think, a real bug. The others were spotted at the same time and are probably not bugs until we start dealing with 40GHz CPus.

Coverity CID 1055682
Coverity CID 1055683

Cc Jan Beulich <[email protected]>
Cc Liu Jinsong <[email protected]>
---
 xen/drivers/cpufreq/cpufreq_ondemand.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/xen/drivers/cpufreq/cpufreq_ondemand.c index b3f9ab8..7fdba03 100644

xen/drivers/cpufreq/cpufreq_ondemand.c +1 -2
@@ -144,7 +144,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s
     *this_dbs_info) }
 
     /* Check for frequency increase */
-    if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
+    if (max_load_freq > (uint64_t) dbs_tuners_ins.up_threshold *
         policy->cur) { /* if we are already at full speed then break
         out early */ if (policy->cur == max)
             return;
@@ -162,7 +162,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s
 *this_dbs_info) 
      * can support the current CPU usage without triggering the up
      * policy. To be safe, we focus 10 points under the threshold.
      */
-    if (max_load_freq < (dbs_tuners_ins.up_threshold - 10) *

policy->cur) { + if (max_load_freq
+ < (uint64_t) (dbs_tuners_ins.up_threshold - 10) *
policy->cur) { uint64_t freq_next;

freq_next = max_load_freq / (dbs_tuners_ins.up_threshold -
10); @@ -246,7 +247,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event)

          * is used for first time
          */
         if ((dbs_enable == 1) && !dbs_tuners_ins.sampling_rate) {
xen/drivers/cpufreq/cpufreq_ondemand.c +1 -1
-            def_sampling_rate = policy->cpuinfo.transition_latency *
+            def_sampling_rate = (uint64_t)
                 policy->cpuinfo.transition_latency *

DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;

Quoted 1 line

if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)

author
#14 lore raw

PATCH 6/9 cpufreq: missing check of copy_from_guest()

In reply to Tim Deegan

Coverity CID 1055131
Coverity CID 1055132

Cc Jan Beulich <[email protected]>
Cc Liu Jinsong <[email protected]>
---
 xen/drivers/cpufreq/cpufreq.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
xen/drivers/cpufreq/cpufreq.c +6 -2
index 0de5d41..ab66884 100644
@@ -471,8 +471,12 @@ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_in
             ret = -ENOMEM;
             goto out;
         }
-        copy_from_guest(pxpt->states, dom0_px_info->states, 
-                                      dom0_px_info->state_count);
+        if ( copy_from_guest(pxpt->states, dom0_px_info->states,
+                             dom0_px_info->state_count) )
+        {
+            ret = -EFAULT;
+            goto out;
+        }
         pxpt->state_count = dom0_px_info->state_count;
 
         if ( cpufreq_verbose )
Signature · 1 line
1.7.10.4
Acked-by on v1 6/9
#15 lore raw

Re: [PATCH 6/9] cpufreq: missing check of copy_from_guest()

Quoted 5 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

Coverity CID 1055131
Coverity CID 1055132

Quoted 26 lines
Cc Liu Jinsong <[email protected]>
---
 xen/drivers/cpufreq/cpufreq.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
xen/drivers/cpufreq/cpufreq.c +6 -2
index 0de5d41..ab66884 100644
@@ -471,8 +471,12 @@ int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *dom0_px_in
             ret = -ENOMEM;
             goto out;
         }
-        copy_from_guest(pxpt->states, dom0_px_info->states, 
-                                      dom0_px_info->state_count);
+        if ( copy_from_guest(pxpt->states, dom0_px_info->states,
+                             dom0_px_info->state_count) )
+        {
+            ret = -EFAULT;
+            goto out;
+        }
         pxpt->state_count = dom0_px_info->state_count;
 
         if ( cpufreq_verbose )
Signature · 1 line
1.7.10.4
Acked-by on v1 6/9
#16 lore raw

Re: [PATCH 6/9] cpufreq: missing check of copy_from_guest()

In reply to Tim Deegan
Quoted 20 lines · Tim Deegan

Coverity CID 1055131
Coverity CID 1055132

Cc Jan Beulich <[email protected]>
Cc Liu Jinsong <[email protected]>
---
 xen/drivers/cpufreq/cpufreq.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
xen/drivers/cpufreq/cpufreq.c +0 -1
index 0de5d41..ab66884 100644
@@ -471,8 +471,12 @@ int set_px_pminfo(uint32_t acpi_id, struct
             xen_processor_performance *dom0_px_in ret = -ENOMEM;
             goto out;
         }
-        copy_from_guest(pxpt->states, dom0_px_info->states,

xen/drivers/cpufreq/cpufreq.c int set_px_pminfo(uint32_t acpi_id, struct · line 482

Quoted 10 lines
xen/drivers/cpufreq/cpufreq.c +6 -1
-                                      dom0_px_info->state_count);
+        if ( copy_from_guest(pxpt->states, dom0_px_info->states,
+                             dom0_px_info->state_count) )
+        {
+            ret = -EFAULT;
+            goto out;
+        }
         pxpt->state_count = dom0_px_info->state_count;
 
         if ( cpufreq_verbose )
author
#17 lore raw

PATCH 7/9 ehci-dbgp: avoid division by zero.

In reply to Tim Deegan

Unlikely to ever see hardware reporting 0 ports, but might as well fail gracefully if we do.

Coverity CID 1055266

---
 xen/drivers/char/ehci-dbgp.c |    3 +++
 1 file changed, 3 insertions(+)
xen/drivers/char/ehci-dbgp.c +3 -0
index 2504979..0ac2dd9 100644
@@ -1099,6 +1099,9 @@ try_next_port:
     dbgp_printk("n_ports:    %u\n", n_ports);
     ehci_dbgp_status(dbgp, "");
 
+    if ( n_ports == 0 )
+        return -1;
+
     for ( i = 1; i <= n_ports; i++ )
     {
         portsc = readl(&dbgp->ehci_regs->port_status[i-1]);
Signature · 1 line
1.7.10.4
Acked-by on v1 7/9
#18 lore raw

Re: [PATCH 7/9] ehci-dbgp: avoid division by zero.

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

Unlikely to ever see hardware reporting 0 ports, but might as well fail gracefully if we do.

Coverity CID 1055266

Well, that's a really pointless change, but anyway:

Quoted 20 lines
---
 xen/drivers/char/ehci-dbgp.c |    3 +++
 1 file changed, 3 insertions(+)
xen/drivers/char/ehci-dbgp.c +3 -0
index 2504979..0ac2dd9 100644
@@ -1099,6 +1099,9 @@ try_next_port:
     dbgp_printk("n_ports:    %u\n", n_ports);
     ehci_dbgp_status(dbgp, "");
 
+    if ( n_ports == 0 )
+        return -1;
+
     for ( i = 1; i <= n_ports; i++ )
     {
         portsc = readl(&dbgp->ehci_regs->port_status[i-1]);
Signature · 1 line
1.7.10.4
author
#19 lore raw

PATCH 8/9 ehci-dbgp: drop dead code.

In reply to Tim Deegan

We can only reach this spot by breaking out of the scan loop, so by construction ret > 0.

Coverity CID 1055259

---
 xen/drivers/char/ehci-dbgp.c |    5 -----
 1 file changed, 5 deletions(-)
xen/drivers/char/ehci-dbgp.c +0 -5
index 0ac2dd9..b900d60 100644
@@ -946,11 +946,6 @@ try_again:
         dbgp_printk("could not find attached debug device\n");
         goto err;
     }
-    if ( ret < 0 )
-    {
-        dbgp_printk("attached device is not a debug device\n");
-        goto err;
-    }
     dbgp->out.endpoint = dbgp_desc.bDebugOutEndpoint;
     dbgp->in.endpoint = dbgp_desc.bDebugInEndpoint;
 
Signature · 1 line
1.7.10.4
Acked-by on v1 8/9
#20 lore raw

Re: [PATCH 8/9] ehci-dbgp: drop dead code.

Quoted 7 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

We can only reach this spot by breaking out of the scan loop, so by construction ret > 0.

Coverity CID 1055259

But this should really be patched in the original (Linux) first...

Quoted 22 lines
---
 xen/drivers/char/ehci-dbgp.c |    5 -----
 1 file changed, 5 deletions(-)
xen/drivers/char/ehci-dbgp.c +0 -5
index 0ac2dd9..b900d60 100644
@@ -946,11 +946,6 @@ try_again:
         dbgp_printk("could not find attached debug device\n");
         goto err;
     }
-    if ( ret < 0 )
-    {
-        dbgp_printk("attached device is not a debug device\n");
-        goto err;
-    }
     dbgp->out.endpoint = dbgp_desc.bDebugOutEndpoint;
     dbgp->in.endpoint = dbgp_desc.bDebugInEndpoint;
 
Signature · 1 line
1.7.10.4
author
#21 lore raw

PATCH 9/9 acpi/pmstat: fix check for empty name strings.

In reply to Tim Deegan

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

---
 xen/drivers/acpi/pmstat.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/drivers/acpi/pmstat.c +2 -2
index f8a9c85..daac2da 100644
@@ -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
Signature · 1 line
1.7.10.4
Acked-by on v1 9/9
#22 lore raw

Re: [PATCH 9/9] acpi/pmstat: fix check for empty name strings.

Quoted 8 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

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

Quoted 27 lines
---
 xen/drivers/acpi/pmstat.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen/drivers/acpi/pmstat.c +2 -2
index f8a9c85..daac2da 100644
@@ -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

Signature · 1 line
1.7.10.4