[dpdk-dev,v2] vfio: fix close unchecked file descriptor
Checks
Commit Message
From: Kuba Kozak <kubax.kozak@intel.com>
Add file descriptor value check before calling close() function.
Coverity issue: 141297
Fixes: 811b6b25060f ("vfio: fix file descriptor leak in multi-process")
Cc: patrick@patrickmacarthur.net
Cc: stable@dpdk.org
Signed-off-by: Kuba Kozak <kubax.kozak@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
v2:
Change check condition
---
lib/librte_eal/linuxapp/eal/eal_vfio_mp_sync.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On 09/21/2017 09:49 AM, Michal Jastrzebski wrote:
> From: Kuba Kozak <kubax.kozak@intel.com>
>
> Add file descriptor value check before calling close() function.
>
> Coverity issue: 141297
> Fixes: 811b6b25060f ("vfio: fix file descriptor leak in multi-process")
> Cc: patrick@patrickmacarthur.net
> Cc: stable@dpdk.org
>
> Signed-off-by: Kuba Kozak <kubax.kozak@intel.com>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
FWIW:
Acked-by: Patrick MacArthur <patrick@patrickmacarthur.net>
21/09/2017 18:07, Patrick MacArthur:
> On 09/21/2017 09:49 AM, Michal Jastrzebski wrote:
> > From: Kuba Kozak <kubax.kozak@intel.com>
> >
> > Add file descriptor value check before calling close() function.
> >
> > Coverity issue: 141297
> > Fixes: 811b6b25060f ("vfio: fix file descriptor leak in multi-process")
> > Cc: patrick@patrickmacarthur.net
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Kuba Kozak <kubax.kozak@intel.com>
> > Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
>
> FWIW:
>
> Acked-by: Patrick MacArthur <patrick@patrickmacarthur.net>
Applied, thanks
@@ -301,7 +301,8 @@ vfio_mp_sync_thread(void __rte_unused * arg)
vfio_mp_sync_send_request(conn_sock, SOCKET_ERR);
else
vfio_mp_sync_send_fd(conn_sock, fd);
- close(fd);
+ if (fd >= 0)
+ close(fd);
break;
case SOCKET_REQ_GROUP:
/* wait for group number */