xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] x86, amd_ucode: Fix coverity issues found in cpu_request_microcode()
@ 2014-07-30 16:12 Aravind Gopalakrishnan
  2014-07-30 16:15 ` Aravind Gopalakrishnan
  2014-07-30 16:25 ` Andrew Cooper
  0 siblings, 2 replies; 3+ messages in thread
From: Aravind Gopalakrishnan @ 2014-07-30 16:12 UTC (permalink / raw)
  To: andrew.cooper3, jbeulich, keir
  Cc: Aravind Gopalakrishnan, coverity, xen-devel

This patch fixes issues found in CID 1229147(dead code) and
CID 1229148: possible resource leak of mc_amd due to goto out
statements.

Reported-by: Andrew Cooper<andrew.cooper3@citrix.com>
Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
---
 xen/arch/x86/microcode_amd.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode_amd.c
index 14728a2..a2bdd20 100644
--- a/xen/arch/x86/microcode_amd.c
+++ b/xen/arch/x86/microcode_amd.c
@@ -384,9 +384,12 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
     while ( offset < bufsize )
     {
         error = install_equiv_cpu_table(mc_amd, buf, &offset);
+        if ( error ) {
+            printk(KERN_ERR "microcode: installing equivalent cpu table failed\n");
+            break;
+        }
 
-        if ( !error &&
-             find_equiv_cpu_id(mc_amd->equiv_cpu_table, current_cpu_id,
+        if ( find_equiv_cpu_id(mc_amd->equiv_cpu_table, current_cpu_id,
                                &equiv_cpu_id) )
                 break;
 
@@ -398,7 +401,7 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
         {
             printk(KERN_ERR "microcode: Microcode buffer overrun\n");
             error = -EINVAL;
-            goto out;
+            break;
         }
 
         error = container_fast_forward(buf, bufsize - offset, &offset);
@@ -407,15 +410,13 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
             printk(KERN_ERR "microcode: CPU%d incorrect or corrupt container file\n"
                    "microcode: Failed to update patch level. "
                    "Current lvl:%#x\n", cpu, uci->cpu_sig.rev);
-            goto out;
+            break;
         }
     }
 
     if ( error )
     {
         xfree(mc_amd);
-        printk(KERN_ERR "microcode: installing equivalent cpu table failed\n");
-        error = -EINVAL;
         goto out;
     }
 
-- 
2.0.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-30 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30 16:12 [PATCH 1/2] x86, amd_ucode: Fix coverity issues found in cpu_request_microcode() Aravind Gopalakrishnan
2014-07-30 16:15 ` Aravind Gopalakrishnan
2014-07-30 16:25 ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).