* [Qemu-devel] [PATCH] chardev-socket: remove useless if
@ 2018-03-20 15:18 Paolo Bonzini
2018-03-20 16:18 ` Marc-André Lureau
2018-03-21 3:25 ` Peter Xu
0 siblings, 2 replies; 5+ messages in thread
From: Paolo Bonzini @ 2018-03-20 15:18 UTC (permalink / raw)
To: qemu-devel
This trips Coverity, which believes the subsequent qio_channel_create_watch
can dereference a NULL pointer. In reality, tcp_chr_connect's callers
all have s->ioc properly initialized, since they are all rooted at
tcp_chr_new_client.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
chardev/char-socket.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index d057192ced..159e69c3b1 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -550,12 +550,10 @@ static void tcp_chr_connect(void *opaque)
s->is_listen, s->is_telnet);
s->connected = 1;
- if (s->ioc) {
- chr->gsource = io_add_watch_poll(chr, s->ioc,
- tcp_chr_read_poll,
- tcp_chr_read,
- chr, chr->gcontext);
- }
+ chr->gsource = io_add_watch_poll(chr, s->ioc,
+ tcp_chr_read_poll,
+ tcp_chr_read,
+ chr, chr->gcontext);
s->hup_source = qio_channel_create_watch(s->ioc, G_IO_HUP);
g_source_set_callback(s->hup_source, (GSourceFunc)tcp_chr_hup,
--
2.16.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] chardev-socket: remove useless if
2018-03-20 15:18 [Qemu-devel] [PATCH] chardev-socket: remove useless if Paolo Bonzini
@ 2018-03-20 16:18 ` Marc-André Lureau
2018-03-21 3:25 ` Peter Xu
1 sibling, 0 replies; 5+ messages in thread
From: Marc-André Lureau @ 2018-03-20 16:18 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: QEMU
On Tue, Mar 20, 2018 at 4:18 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> This trips Coverity, which believes the subsequent qio_channel_create_watch
> can dereference a NULL pointer. In reality, tcp_chr_connect's callers
> all have s->ioc properly initialized, since they are all rooted at
> tcp_chr_new_client.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> chardev/char-socket.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/chardev/char-socket.c b/chardev/char-socket.c
> index d057192ced..159e69c3b1 100644
> --- a/chardev/char-socket.c
> +++ b/chardev/char-socket.c
> @@ -550,12 +550,10 @@ static void tcp_chr_connect(void *opaque)
> s->is_listen, s->is_telnet);
>
> s->connected = 1;
> - if (s->ioc) {
> - chr->gsource = io_add_watch_poll(chr, s->ioc,
> - tcp_chr_read_poll,
> - tcp_chr_read,
> - chr, chr->gcontext);
> - }
> + chr->gsource = io_add_watch_poll(chr, s->ioc,
> + tcp_chr_read_poll,
> + tcp_chr_read,
> + chr, chr->gcontext);
>
> s->hup_source = qio_channel_create_watch(s->ioc, G_IO_HUP);
> g_source_set_callback(s->hup_source, (GSourceFunc)tcp_chr_hup,
> --
> 2.16.2
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] chardev-socket: remove useless if
2018-03-20 15:18 [Qemu-devel] [PATCH] chardev-socket: remove useless if Paolo Bonzini
2018-03-20 16:18 ` Marc-André Lureau
@ 2018-03-21 3:25 ` Peter Xu
2018-03-21 5:50 ` Paolo Bonzini
1 sibling, 1 reply; 5+ messages in thread
From: Peter Xu @ 2018-03-21 3:25 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Tue, Mar 20, 2018 at 04:18:57PM +0100, Paolo Bonzini wrote:
> This trips Coverity, which believes the subsequent qio_channel_create_watch
> can dereference a NULL pointer. In reality, tcp_chr_connect's callers
> all have s->ioc properly initialized, since they are all rooted at
> tcp_chr_new_client.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(maybe replacing with an assertion would be nicer? No big deal.)
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] chardev-socket: remove useless if
2018-03-21 3:25 ` Peter Xu
@ 2018-03-21 5:50 ` Paolo Bonzini
2018-03-21 6:34 ` Peter Xu
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2018-03-21 5:50 UTC (permalink / raw)
To: Peter Xu; +Cc: qemu-devel
On 21/03/2018 04:25, Peter Xu wrote:
> On Tue, Mar 20, 2018 at 04:18:57PM +0100, Paolo Bonzini wrote:
>> This trips Coverity, which believes the subsequent qio_channel_create_watch
>> can dereference a NULL pointer. In reality, tcp_chr_connect's callers
>> all have s->ioc properly initialized, since they are all rooted at
>> tcp_chr_new_client.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>
> (maybe replacing with an assertion would be nicer? No big deal.)
It's already asserting, it just raises SIGSEGV instead of SIGABRT. :)
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] chardev-socket: remove useless if
2018-03-21 5:50 ` Paolo Bonzini
@ 2018-03-21 6:34 ` Peter Xu
0 siblings, 0 replies; 5+ messages in thread
From: Peter Xu @ 2018-03-21 6:34 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Wed, Mar 21, 2018 at 06:50:46AM +0100, Paolo Bonzini wrote:
> On 21/03/2018 04:25, Peter Xu wrote:
> > On Tue, Mar 20, 2018 at 04:18:57PM +0100, Paolo Bonzini wrote:
> >> This trips Coverity, which believes the subsequent qio_channel_create_watch
> >> can dereference a NULL pointer. In reality, tcp_chr_connect's callers
> >> all have s->ioc properly initialized, since they are all rooted at
> >> tcp_chr_new_client.
> >>
> >> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >
> > (maybe replacing with an assertion would be nicer? No big deal.)
>
> It's already asserting, it just raises SIGSEGV instead of SIGABRT. :)
Ah yes it's in the next qio_channel_create_watch(). :)
--
Peter Xu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-03-21 6:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-20 15:18 [Qemu-devel] [PATCH] chardev-socket: remove useless if Paolo Bonzini
2018-03-20 16:18 ` Marc-André Lureau
2018-03-21 3:25 ` Peter Xu
2018-03-21 5:50 ` Paolo Bonzini
2018-03-21 6:34 ` Peter Xu
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).