On 05/08/2017 03:45 PM, Stefano Stabellini wrote:
> Fix two resource leaks on error paths, discovered by Coverity.
> Check for errors returned by fcntl, also found by Coverity.
> 
> CID:1374836
> CID:1374831
> 

> @@ -378,7 +380,10 @@ static int xen_9pfs_connect(struct XenDevice *xendev)
>          if (xen_9pdev->rings[i].evtchndev == NULL) {
>              goto out;
>          }
> -        fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev), F_SETFD, 
> FD_CLOEXEC);
> +        if (fcntl(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
> +                  F_SETFD, FD_CLOEXEC) == -1) {
> +            goto out;

Directly calling fcntl(F_SETFD) without first reading fcntl(F_GETFD) is
(theoretically) incorrect.  Better might be using qemu_set_cloexec()
instead of open-coding something.

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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to