On 11 July 2017 at 20:08, Dr. David Alan Gilbert <dgilb...@redhat.com> wrote: > * Peter Maydell (peter.mayd...@linaro.org) wrote: >> [cc'd Eric as the sort of person >> >> On 11 July 2017 at 17:29, Dr. David Alan Gilbert <dgilb...@redhat.com> wrote: >> > * Peter Maydell (peter.mayd...@linaro.org) wrote: >> >> In a fork_exec() error path we try to closesocket(s) when s might >> >> be a negative number because the thing that failed was the >> >> qemu_socket() call. Add a guard so we don't do this. >> >> >> >> (Spotted by Coverity: CID 1005727 issue 1 of 2.) >> >> >> >> Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> >> >> --- >> >> Issue 2 of 2 in CID 1005727 is trickier -- we need to move as >> >> much as possible of the client-end connect/accept out of the >> >> child process and into the parent as possible. I'm not sure >> >> if it's safe to do it all in the parent without deadlocking... >> > >> > or just bail earlier? >> >> The problem is you can only bail while you're in the parent >> before forking. Once you've started the child there's no >> mechanism for dealing with failure. > > Well, you can always exit the child before anything worse can happen.
You need a mechanism then for causing the parent to notice. The current code would leave the parent in a blocking accept() call forever (this is what all the XXX comments in the current code are about). thanks -- PMM