diff mbox

Added negative check for get_image_size()

Message ID 1461598566-28454-1-git-send-email-zhoujie2011@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhou Jie April 25, 2016, 3:36 p.m. UTC
This patch adds check for negative return value from get_image_size(),
where it is missing. It avoids unnecessary two function calls.

Signed-off-by: Zhou Jie <zhoujie2011@cn.fujitsu.com>
---
 hw/ppc/spapr.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

David Gibson April 26, 2016, 2:02 a.m. UTC | #1
On Mon, Apr 25, 2016 at 11:36:06AM -0400, Zhou Jie wrote:
> This patch adds check for negative return value from get_image_size(),
> where it is missing. It avoids unnecessary two function calls.
> 
> Signed-off-by: Zhou Jie <zhoujie2011@cn.fujitsu.com>

Applied to ppc-for-2.7, thanks.

> ---
>  hw/ppc/spapr.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index feaab08..ccea633 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1842,6 +1842,10 @@ static void ppc_spapr_init(MachineState *machine)
>          exit(1);
>      }
>      spapr->rtas_size = get_image_size(filename);
> +    if (spapr->rtas_size < 0) {
> +        error_report("Could not get size of LPAR rtas '%s'", filename);
> +        exit(1);
> +    }
>      spapr->rtas_blob = g_malloc(spapr->rtas_size);
>      if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0) {
>          error_report("Could not load LPAR rtas '%s'", filename);
diff mbox

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index feaab08..ccea633 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1842,6 +1842,10 @@  static void ppc_spapr_init(MachineState *machine)
         exit(1);
     }
     spapr->rtas_size = get_image_size(filename);
+    if (spapr->rtas_size < 0) {
+        error_report("Could not get size of LPAR rtas '%s'", filename);
+        exit(1);
+    }
     spapr->rtas_blob = g_malloc(spapr->rtas_size);
     if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0) {
         error_report("Could not load LPAR rtas '%s'", filename);