All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] cpus: Fix botched configure_icount() error API violation fix
@ 2020-05-15  4:22 Markus Armbruster
  2020-05-15  6:44 ` Philippe Mathieu-Daudé
  2020-05-21 15:08 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Armbruster @ 2020-05-15  4:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, philmd, peter.maydell

Before recent commit abc9bf69a66, configure_icount() returned early
when option "shift" was absent: succeed when option "align" was also
absent, else fail.

Since then, it still errors out when only "align" is present, but
continues when both are absent.  Crashes when examining the value of
"shift" further.  Reproducer: -icount "".

Revert this erroneous part of the commit.

Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes: Coverity CID 1428754
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 cpus.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cpus.c b/cpus.c
index 5670c96bcf..ee906dd08f 100644
--- a/cpus.c
+++ b/cpus.c
@@ -803,8 +803,10 @@ void configure_icount(QemuOpts *opts, Error **errp)
     bool align = qemu_opt_get_bool(opts, "align", false);
     long time_shift = -1;
 
-    if (!option && qemu_opt_get(opts, "align")) {
-        error_setg(errp, "Please specify shift option when using align");
+    if (!option) {
+        if (qemu_opt_get(opts, "align") != NULL) {
+            error_setg(errp, "Please specify shift option when using align");
+        }
         return;
     }
 
-- 
2.21.1



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

* Re: [PATCH v2] cpus: Fix botched configure_icount() error API violation fix
  2020-05-15  4:22 [PATCH v2] cpus: Fix botched configure_icount() error API violation fix Markus Armbruster
@ 2020-05-15  6:44 ` Philippe Mathieu-Daudé
  2020-05-21 15:08 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-15  6:44 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: pbonzini, peter.maydell

On 5/15/20 6:22 AM, Markus Armbruster wrote:
> Before recent commit abc9bf69a66, configure_icount() returned early
> when option "shift" was absent: succeed when option "align" was also
> absent, else fail.
> 
> Since then, it still errors out when only "align" is present, but
> continues when both are absent.  Crashes when examining the value of
> "shift" further.  Reproducer: -icount "".
> 
> Revert this erroneous part of the commit.
> 
> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
> Fixes: Coverity CID 1428754
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   cpus.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 5670c96bcf..ee906dd08f 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -803,8 +803,10 @@ void configure_icount(QemuOpts *opts, Error **errp)
>       bool align = qemu_opt_get_bool(opts, "align", false);
>       long time_shift = -1;
>   
> -    if (!option && qemu_opt_get(opts, "align")) {
> -        error_setg(errp, "Please specify shift option when using align");
> +    if (!option) {
> +        if (qemu_opt_get(opts, "align") != NULL) {

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> +            error_setg(errp, "Please specify shift option when using align");
> +        }
>           return;
>       }
>   
> 



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

* Re: [PATCH v2] cpus: Fix botched configure_icount() error API violation fix
  2020-05-15  4:22 [PATCH v2] cpus: Fix botched configure_icount() error API violation fix Markus Armbruster
  2020-05-15  6:44 ` Philippe Mathieu-Daudé
@ 2020-05-21 15:08 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-05-21 15:08 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: peter.maydell, philmd

On 15/05/20 06:22, Markus Armbruster wrote:
> Before recent commit abc9bf69a66, configure_icount() returned early
> when option "shift" was absent: succeed when option "align" was also
> absent, else fail.
> 
> Since then, it still errors out when only "align" is present, but
> continues when both are absent.  Crashes when examining the value of
> "shift" further.  Reproducer: -icount "".
> 
> Revert this erroneous part of the commit.
> 
> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
> Fixes: Coverity CID 1428754
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  cpus.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 5670c96bcf..ee906dd08f 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -803,8 +803,10 @@ void configure_icount(QemuOpts *opts, Error **errp)
>      bool align = qemu_opt_get_bool(opts, "align", false);
>      long time_shift = -1;
>  
> -    if (!option && qemu_opt_get(opts, "align")) {
> -        error_setg(errp, "Please specify shift option when using align");
> +    if (!option) {
> +        if (qemu_opt_get(opts, "align") != NULL) {
> +            error_setg(errp, "Please specify shift option when using align");
> +        }
>          return;
>      }
>  
> 

Got the nicer commit message, too.

Paolo



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

end of thread, other threads:[~2020-05-21 15:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15  4:22 [PATCH v2] cpus: Fix botched configure_icount() error API violation fix Markus Armbruster
2020-05-15  6:44 ` Philippe Mathieu-Daudé
2020-05-21 15:08 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.