qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] util/oslib-posix: Fix missing unlock in the error path of os_mem_prealloc()
@ 2022-01-11 12:08 David Hildenbrand
  2022-01-11 12:56 ` Pankaj Gupta
  0 siblings, 1 reply; 2+ messages in thread
From: David Hildenbrand @ 2022-01-11 12:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P . Berrangé, Michael S . Tsirkin, Michal Privoznik,
	David Hildenbrand, Pankaj Gupta, Paolo Bonzini

We're missing an unlock in case installing the signal handler failed.
Fortunately, we barely see this error in real life.

Fixes: a960d6642d39 ("util/oslib-posix: Support concurrent os_mem_prealloc() invocation")
Fixes: CID 1468941
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Pankaj Gupta <pankaj.gupta@ionos.com>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 util/oslib-posix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 9efdc74bba..ac0dbc2adc 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -683,6 +683,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus,
 
         ret = sigaction(SIGBUS, &act, &sigbus_oldact);
         if (ret) {
+            qemu_mutex_unlock(&sigbus_mutex);
             error_setg_errno(errp, errno,
                 "os_mem_prealloc: failed to install signal handler");
             return;
-- 
2.33.1



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

* Re: [PATCH v1] util/oslib-posix: Fix missing unlock in the error path of os_mem_prealloc()
  2022-01-11 12:08 [PATCH v1] util/oslib-posix: Fix missing unlock in the error path of os_mem_prealloc() David Hildenbrand
@ 2022-01-11 12:56 ` Pankaj Gupta
  0 siblings, 0 replies; 2+ messages in thread
From: Pankaj Gupta @ 2022-01-11 12:56 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Michal Privoznik, Paolo Bonzini, Daniel P . Berrangé,
	qemu-devel, Michael S . Tsirkin

> We're missing an unlock in case installing the signal handler failed.
> Fortunately, we barely see this error in real life.
>
> Fixes: a960d6642d39 ("util/oslib-posix: Support concurrent os_mem_prealloc() invocation")
> Fixes: CID 1468941
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Pankaj Gupta <pankaj.gupta@ionos.com>
> Cc: Daniel P. Berrangé <berrange@redhat.com>
> Cc: Michal Privoznik <mprivozn@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  util/oslib-posix.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 9efdc74bba..ac0dbc2adc 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -683,6 +683,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory, int smp_cpus,
>
>          ret = sigaction(SIGBUS, &act, &sigbus_oldact);
>          if (ret) {
> +            qemu_mutex_unlock(&sigbus_mutex);
>              error_setg_errno(errp, errno,
>                  "os_mem_prealloc: failed to install signal handler");
>              return;
> --

Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com>

> 2.33.1
>


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

end of thread, other threads:[~2022-01-11 13:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-11 12:08 [PATCH v1] util/oslib-posix: Fix missing unlock in the error path of os_mem_prealloc() David Hildenbrand
2022-01-11 12:56 ` Pankaj Gupta

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).