crtools: Make fdset operations robust against open() errors
There are two cases for cr_fdset_open - It might be called with already allocated memory so we should reuse it. - It might be called with NULL pointing out that caller expects us to allocate memory. If an open() error happens somewhere inside cr_fdset_open it requires two error paths - Just close all files opened but don't free memory if it was not allocated by us - Close all files opened *and* free memory allocated by us. In any case we should close all files opened so close_cr_fdset() helper is splitted into two parts. Also the caller should be ready for such semantics as well and do not re-assign pointers obtained but simply test for NULL on results. Signed-off-by:Cyrill Gorcunov <gorcunov@openvz.org> Acked-by:
Pavel Emelyanov <xemul@parallels.com>
Showing
Please
register
or
sign in
to comment