qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
@ 2019-09-10  7:59 Vladimir Sementsov-Ogievskiy
  2019-09-10  8:03 ` Daniel P. Berrangé
  2019-09-10  9:37 ` Stefano Garzarella
  0 siblings, 2 replies; 7+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-09-10  7:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, vsementsov, berrange, kraxel, den

In "if (saddr->keep_alive) {" we may already be on error path, with
invalid sock < 0. Fix it by returning error earlier.

Reported-by: Coverity (CID 1405300)
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 util/qemu-sockets.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 98ff3a1cce..bcc06d0e01 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -461,12 +461,13 @@ int inet_connect_saddr(InetSocketAddress *saddr, Error **errp)
         }
     }
 
+    freeaddrinfo(res);
+
     if (sock < 0) {
         error_propagate(errp, local_err);
+        return sock;
     }
 
-    freeaddrinfo(res);
-
     if (saddr->keep_alive) {
         int val = 1;
         int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
-- 
2.18.0



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

* Re: [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
  2019-09-10  7:59 [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr Vladimir Sementsov-Ogievskiy
@ 2019-09-10  8:03 ` Daniel P. Berrangé
  2019-09-10 13:59   ` Eric Blake
  2019-09-10  9:37 ` Stefano Garzarella
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel P. Berrangé @ 2019-09-10  8:03 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy; +Cc: den, peter.maydell, qemu-devel, kraxel

On Tue, Sep 10, 2019 at 10:59:43AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> In "if (saddr->keep_alive) {" we may already be on error path, with
> invalid sock < 0. Fix it by returning error earlier.
> 
> Reported-by: Coverity (CID 1405300)
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  util/qemu-sockets.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


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

* Re: [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
  2019-09-10  7:59 [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr Vladimir Sementsov-Ogievskiy
  2019-09-10  8:03 ` Daniel P. Berrangé
@ 2019-09-10  9:37 ` Stefano Garzarella
  1 sibling, 0 replies; 7+ messages in thread
From: Stefano Garzarella @ 2019-09-10  9:37 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy
  Cc: den, peter.maydell, berrange, qemu-devel, kraxel

On Tue, Sep 10, 2019 at 10:59:43AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> In "if (saddr->keep_alive) {" we may already be on error path, with
> invalid sock < 0. Fix it by returning error earlier.
> 
> Reported-by: Coverity (CID 1405300)
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  util/qemu-sockets.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>


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

* Re: [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
  2019-09-10  8:03 ` Daniel P. Berrangé
@ 2019-09-10 13:59   ` Eric Blake
  2019-09-11 12:08     ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Blake @ 2019-09-10 13:59 UTC (permalink / raw)
  To: Daniel P. Berrangé, Vladimir Sementsov-Ogievskiy
  Cc: den, kraxel, qemu-devel, peter.maydell


[-- Attachment #1.1: Type: text/plain, Size: 827 bytes --]

On 9/10/19 3:03 AM, Daniel P. Berrangé wrote:
> On Tue, Sep 10, 2019 at 10:59:43AM +0300, Vladimir Sementsov-Ogievskiy wrote:
>> In "if (saddr->keep_alive) {" we may already be on error path, with
>> invalid sock < 0. Fix it by returning error earlier.
>>
>> Reported-by: Coverity (CID 1405300)
>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>  util/qemu-sockets.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Thanks.  Will queue through my NBD tree, since that's where the original
problem was introduced.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
  2019-09-10 13:59   ` Eric Blake
@ 2019-09-11 12:08     ` Vladimir Sementsov-Ogievskiy
  2019-09-25 11:33       ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-09-11 12:08 UTC (permalink / raw)
  To: Eric Blake, Daniel P. Berrangé
  Cc: peter.maydell, kraxel, Denis Lunev, qemu-devel

10.09.2019 16:59, Eric Blake wrote:
> On 9/10/19 3:03 AM, Daniel P. Berrangé wrote:
>> On Tue, Sep 10, 2019 at 10:59:43AM +0300, Vladimir Sementsov-Ogievskiy wrote:
>>> In "if (saddr->keep_alive) {" we may already be on error path, with
>>> invalid sock < 0. Fix it by returning error earlier.
>>>
>>> Reported-by: Coverity (CID 1405300)
>>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>> ---
>>>   util/qemu-sockets.c | 5 +++--
>>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> 
> Thanks.  Will queue through my NBD tree, since that's where the original
> problem was introduced.
> 

Please add when queueing:

Fixes: aec21d31756cbd

-- 
Best regards,
Vladimir

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

* Re: [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
  2019-09-11 12:08     ` Vladimir Sementsov-Ogievskiy
@ 2019-09-25 11:33       ` Vladimir Sementsov-Ogievskiy
  2019-09-25 13:13         ` Eric Blake
  0 siblings, 1 reply; 7+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2019-09-25 11:33 UTC (permalink / raw)
  To: Eric Blake, Daniel P. Berrangé
  Cc: peter.maydell, kraxel, Denis Lunev, qemu-devel

11.09.2019 15:08, Vladimir Sementsov-Ogievskiy wrote:
> 10.09.2019 16:59, Eric Blake wrote:
>> On 9/10/19 3:03 AM, Daniel P. Berrangé wrote:
>>> On Tue, Sep 10, 2019 at 10:59:43AM +0300, Vladimir Sementsov-Ogievskiy wrote:
>>>> In "if (saddr->keep_alive) {" we may already be on error path, with
>>>> invalid sock < 0. Fix it by returning error earlier.
>>>>
>>>> Reported-by: Coverity (CID 1405300)
>>>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>>> ---
>>>>   util/qemu-sockets.c | 5 +++--
>>>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>>
>> Thanks.  Will queue through my NBD tree, since that's where the original
>> problem was introduced.
>>
> 
> Please add when queueing:
> 
> Fixes: aec21d31756cbd
> 

Hmm, don't you forget? Don't see it neither in pull request nor in your branches.

-- 
Best regards,
Vladimir

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

* Re: [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
  2019-09-25 11:33       ` Vladimir Sementsov-Ogievskiy
@ 2019-09-25 13:13         ` Eric Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2019-09-25 13:13 UTC (permalink / raw)
  To: Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé
  Cc: peter.maydell, kraxel, Denis Lunev, qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 1242 bytes --]

On 9/25/19 6:33 AM, Vladimir Sementsov-Ogievskiy wrote:
> 11.09.2019 15:08, Vladimir Sementsov-Ogievskiy wrote:
>> 10.09.2019 16:59, Eric Blake wrote:
>>> On 9/10/19 3:03 AM, Daniel P. Berrangé wrote:
>>>> On Tue, Sep 10, 2019 at 10:59:43AM +0300, Vladimir Sementsov-Ogievskiy wrote:
>>>>> In "if (saddr->keep_alive) {" we may already be on error path, with
>>>>> invalid sock < 0. Fix it by returning error earlier.
>>>>>
>>>>> Reported-by: Coverity (CID 1405300)
>>>>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>>>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>>>> ---
>>>>>   util/qemu-sockets.c | 5 +++--
>>>>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>>>
>>>> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>>>
>>> Thanks.  Will queue through my NBD tree, since that's where the original
>>> problem was introduced.
>>>
>>
>> Please add when queueing:
>>
>> Fixes: aec21d31756cbd
>>
> 
> Hmm, don't you forget? Don't see it neither in pull request nor in your branches.

Thanks for catching this.  Fixing now...

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2019-09-25 13:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-10  7:59 [Qemu-devel] [PATCH] util/qemu-sockets: fix keep_alive handling in inet_connect_saddr Vladimir Sementsov-Ogievskiy
2019-09-10  8:03 ` Daniel P. Berrangé
2019-09-10 13:59   ` Eric Blake
2019-09-11 12:08     ` Vladimir Sementsov-Ogievskiy
2019-09-25 11:33       ` Vladimir Sementsov-Ogievskiy
2019-09-25 13:13         ` Eric Blake
2019-09-10  9:37 ` Stefano Garzarella

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