[rds-devel] [PATCH net] rds: Incorrect reference counting in TCP socket creation
Sowmini Varadhan
sowmini.varadhan at oracle.com
Thu Mar 1 04:31:18 PST 2018
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
More information about the rds-devel
mailing list