From ec81f44ff9beeb9c163b4cd01456d190dd47a7a9 Mon Sep 17 00:00:00 2001 From: Bluebear233 <417350690@qq.com> Date: Sun, 27 May 2018 21:37:08 +0800 Subject: [PATCH] Update net_sockets.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复创建socket失败仍然返回有效的fd --- components/dfs/filesystems/net/net_sockets.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/dfs/filesystems/net/net_sockets.c b/components/dfs/filesystems/net/net_sockets.c index 4f33571129..802cd05b7c 100644 --- a/components/dfs/filesystems/net/net_sockets.c +++ b/components/dfs/filesystems/net/net_sockets.c @@ -316,6 +316,16 @@ int socket(int domain, int type, int protocol) rt_list_init(&(lwsock->wait_head)); lwsock->conn->callback = event_callback; } + else + { + /* release fd */ + fd_put(d); + fd_put(d); + + rt_set_errno(-ENOMEM); + + return -1; + } /* release the ref-count of fd */ fd_put(d);