From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aserp2130.oracle.com ([141.146.126.79]:33166 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030313AbeCAMby (ORCPT ); Thu, 1 Mar 2018 07:31:54 -0500 Date: Thu, 1 Mar 2018 07:31:18 -0500 From: Sowmini Varadhan To: Ka-Cheong Poon Cc: Sowmini Varadhan , netdev , santosh.shilimkar@oracle.com, David Miller , rds-devel@oss.oracle.com Subject: Re: [PATCH net] rds: Incorrect reference counting in TCP socket creation Message-ID: <20180301123118.GB28739@oracle.com> References: <3403bcbebd03837eec0f86a346daf5c109db2a19.1519879295.git.ka-cheong.poon@oracle.com> <7940eadb-a01c-172f-5c57-e372993f4bd9@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7940eadb-a01c-172f-5c57-e372993f4bd9@oracle.com> Sender: netdev-owner@vger.kernel.org List-ID: On (03/01/18 20:19), Ka-Cheong Poon wrote: > >> > >>- new_sock->type = sock->type; > >>- new_sock->ops = sock->ops; > >> ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, true); > >> if (ret < 0) > >> goto out; > >> > >>+ new_sock->ops = sock->ops; > > > >How is this delta relevant to the commit comment? Seems unrelated? > > > Note that sock_release() checks if sock->ops is set before > decrementing the refcnt. By moving the ops assignment after > the ops->accept() call, we save increasing the refcnt in > case the ops->accept() fails. Otherwise, the __module_get() > needs to be moved before ops->accept() to handle this failure > case. I see, thanks for clarification. It may be helpful to have some comment in there, in case some other module trips on something similar in the future. --Sowmini