[Qemu-devel] [PATCH v2] spapr: return from post_load method when RTC import fails

Cédric Le Goater posted 1 patch 5 years, 3 months ago
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test docker-clang@ubuntu passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190104133050.7468-1-clg@kaod.org
hw/ppc/spapr.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH v2] spapr: return from post_load method when RTC import fails
Posted by Cédric Le Goater 5 years, 3 months ago
The error value can be squashed by the section handling radix migration.
Simply bail out if an error occurs when the RTC offset is imported.

This fixes the Coverity issue CID 1398591.

Fixes: d39c90f5f3ae ("spapr: Fix migration of Radix guests")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

 Changes since v1 :

 - Added Coverity issue CID

 hw/ppc/spapr.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f1725313e979..64397ee91ef0 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1748,12 +1748,17 @@ static int spapr_post_load(void *opaque, int version_id)
         return err;
     }
 
-    /* In earlier versions, there was no separate qdev for the PAPR
+    /*
+     * In earlier versions, there was no separate qdev for the PAPR
      * RTC, so the RTC offset was stored directly in sPAPREnvironment.
      * So when migrating from those versions, poke the incoming offset
-     * value into the RTC device */
+     * value into the RTC device
+     */
     if (version_id < 3) {
         err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
+        if (err) {
+            return err;
+        }
     }
 
     if (kvm_enabled() && spapr->patb_entry) {
-- 
2.20.1


Re: [Qemu-devel] [Qemu-ppc] [PATCH v2] spapr: return from post_load method when RTC import fails
Posted by Greg Kurz 5 years, 3 months ago
On Fri,  4 Jan 2019 14:30:50 +0100
Cédric Le Goater <clg@kaod.org> wrote:

> The error value can be squashed by the section handling radix migration.
> Simply bail out if an error occurs when the RTC offset is imported.
> 
> This fixes the Coverity issue CID 1398591.
> 
> Fixes: d39c90f5f3ae ("spapr: Fix migration of Radix guests")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> 

Reviewed-by: Greg Kurz <groug@kaod.org>

>  Changes since v1 :
> 
>  - Added Coverity issue CID
> 
>  hw/ppc/spapr.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f1725313e979..64397ee91ef0 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1748,12 +1748,17 @@ static int spapr_post_load(void *opaque, int version_id)
>          return err;
>      }
>  
> -    /* In earlier versions, there was no separate qdev for the PAPR
> +    /*
> +     * In earlier versions, there was no separate qdev for the PAPR
>       * RTC, so the RTC offset was stored directly in sPAPREnvironment.
>       * So when migrating from those versions, poke the incoming offset
> -     * value into the RTC device */
> +     * value into the RTC device
> +     */
>      if (version_id < 3) {
>          err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
> +        if (err) {
> +            return err;
> +        }
>      }
>  
>      if (kvm_enabled() && spapr->patb_entry) {


Re: [Qemu-devel] [PATCH v2] spapr: return from post_load method when RTC import fails
Posted by David Gibson 5 years, 3 months ago
On Fri, Jan 04, 2019 at 02:30:50PM +0100, Cédric Le Goater wrote:
> The error value can be squashed by the section handling radix migration.
> Simply bail out if an error occurs when the RTC offset is imported.
> 
> This fixes the Coverity issue CID 1398591.
> 
> Fixes: d39c90f5f3ae ("spapr: Fix migration of Radix guests")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Applied to ppc-for-4.0, thanks.

> ---
> 
>  Changes since v1 :
> 
>  - Added Coverity issue CID
> 
>  hw/ppc/spapr.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f1725313e979..64397ee91ef0 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1748,12 +1748,17 @@ static int spapr_post_load(void *opaque, int version_id)
>          return err;
>      }
>  
> -    /* In earlier versions, there was no separate qdev for the PAPR
> +    /*
> +     * In earlier versions, there was no separate qdev for the PAPR
>       * RTC, so the RTC offset was stored directly in sPAPREnvironment.
>       * So when migrating from those versions, poke the incoming offset
> -     * value into the RTC device */
> +     * value into the RTC device
> +     */
>      if (version_id < 3) {
>          err = spapr_rtc_import_offset(&spapr->rtc, spapr->rtc_offset);
> +        if (err) {
> +            return err;
> +        }
>      }
>  
>      if (kvm_enabled() && spapr->patb_entry) {

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson