Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3306517ybn; Fri, 27 Sep 2019 04:29:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqxkuBez4O2Gsa21JzbeBSkAbylpkxZkIvUg64vZyyQqDXL25uhlgjr5S8I3o9eHQcIsSO X-Received: by 2002:a05:6402:150a:: with SMTP id f10mr3807719edw.110.1569583775785; Fri, 27 Sep 2019 04:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569583775; cv=none; d=google.com; s=arc-20160816; b=XbkT6h/WeoAAHTI6zuIkRuFB4SI9jcfim4exRSJSdQmESjPs3yRUv2bPCi5y2keozN ARn5KKRXzdjfEZSCp1AvQQbjNpdiGY90knz9/QfKjBeBfzkYXn/NP+kzhKw45wCLOWzg p2aNbK4ubX2CvpQCXI3Sh0+ydLAwZIY7m1CjfrpPLiPEyTOb2V7MBvAvi4/ITX1d8SwW X92qz0pUyuJtG+g/w3kZggX7nEcIqtjLL0VppOphth4d9KUzuD1xsYprnTj4dkhdfqsg wdqzaCfRioTxN19bXbXNWTNH8v86krU29l4pMzUkKu7pcYBxHy/PMBmClR/Rsv42raa3 C/Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=qHD/RMyYSu59Y81jIvgFtvqiytPlPoM8Pd5u73l/SRg=; b=UxpSej6R43lHZngGrEOuOerPMUhvtoSW95my0TvX/KXRi6ysd3eBJ1gT00evdmbG5O 3DU5IMK8dA2qUcAzjeGFQw9o/ZpybxJC2LPKcJhvCAP1D7+joXSuy3hm/sOhvx3REOls /kz8pw7EgHvAOyAn0qNv3PReGfCkjz77Yie//JzFKKJcGcwWEgXP55e4g/h86VBNDBR+ We9QB/6/BrOoK4blmNvshK8DO6m8Xy7nNDVI40tsWRjcj99BcNDydITodV9cNPm623UJ 9HG2be1OhaBFMbNRwfrWuSldn/B+PWelGvuK8OvgDsnOuKn+1R4Y3I1+200Bx+3A3TEy VUSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si2429581ejw.276.2019.09.27.04.29.11; Fri, 27 Sep 2019 04:29:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbfI0L2V (ORCPT + 99 others); Fri, 27 Sep 2019 07:28:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51654 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727542AbfI0L2U (ORCPT ); Fri, 27 Sep 2019 07:28:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06E9718C892A; Fri, 27 Sep 2019 11:28:20 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-117-249.ams2.redhat.com [10.36.117.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0E245D9C3; Fri, 27 Sep 2019 11:28:16 +0000 (UTC) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: linux-hyperv@vger.kernel.org, "K. Y. Srinivasan" , Stefan Hajnoczi , Sasha Levin , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "David S. Miller" , virtualization@lists.linux-foundation.org, Stephen Hemminger , Jason Wang , "Michael S. Tsirkin" , Haiyang Zhang , Dexuan Cui , Jorgen Hansen Subject: [RFC PATCH 08/13] vsock: move vsock_insert_unbound() in the vsock_create() Date: Fri, 27 Sep 2019 13:26:58 +0200 Message-Id: <20190927112703.17745-9-sgarzare@redhat.com> In-Reply-To: <20190927112703.17745-1-sgarzare@redhat.com> References: <20190927112703.17745-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Fri, 27 Sep 2019 11:28:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org vsock_insert_unbound() was called only when 'sock' parameter of __vsock_create() was not null. This only happened when __vsock_create() was called by vsock_create(). In order to simplify the multi-transports support, this patch moves vsock_insert_unbound() at the end of vsock_create(). Signed-off-by: Stefano Garzarella --- net/vmw_vsock/af_vsock.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index dee69d7ee148..95e6db21e7e1 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -634,9 +634,6 @@ struct sock *__vsock_create(struct net *net, return NULL; } - if (sock) - vsock_insert_unbound(vsk); - return sk; } EXPORT_SYMBOL_GPL(__vsock_create); @@ -1875,6 +1872,8 @@ static const struct proto_ops vsock_stream_ops = { static int vsock_create(struct net *net, struct socket *sock, int protocol, int kern) { + struct sock *sk; + if (!sock) return -EINVAL; @@ -1894,7 +1893,13 @@ static int vsock_create(struct net *net, struct socket *sock, sock->state = SS_UNCONNECTED; - return __vsock_create(net, sock, NULL, GFP_KERNEL, 0, kern) ? 0 : -ENOMEM; + sk = __vsock_create(net, sock, NULL, GFP_KERNEL, 0, kern); + if (!sk) + return -ENOMEM; + + vsock_insert_unbound(vsock_sk(sk)); + + return 0; } static const struct net_proto_family vsock_family_ops = { -- 2.21.0