netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Yasevich <vyasevich@gmail.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: Wei Yongjun <weiyj.lk@gmail.com>,
	davem@davemloft.net, yongjun_wei@trendmicro.com.cn,
	linux-sctp@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH -next] sctp: fix error return code in __sctp_connect()
Date: Wed, 03 Apr 2013 10:52:16 -0400	[thread overview]
Message-ID: <515C4220.6030802@gmail.com> (raw)
In-Reply-To: <20130403135126.GA32276@hmsreliant.think-freely.org>

On 04/03/2013 09:51 AM, Neil Horman wrote:
> On Wed, Apr 03, 2013 at 09:02:28PM +0800, Wei Yongjun wrote:
>> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>>
>> Fix to return a negative error code from the error handling
>> case instead of 0, as returned elsewhere in this function.
>>
>> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>> ---
>>   net/sctp/socket.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
>> index dd21ae3..f631c5f 100644
>> --- a/net/sctp/socket.c
>> +++ b/net/sctp/socket.c
>> @@ -1119,9 +1119,10 @@ static int __sctp_connect(struct sock* sk,
>>   		/* Make sure the destination port is correctly set
>>   		 * in all addresses.
>>   		 */
>> -		if (asoc && asoc->peer.port && asoc->peer.port != port)
>> +		if (asoc && asoc->peer.port && asoc->peer.port != port) {
>> +			err = -EINVAL;
>>   			goto out_free;
>> -
>> +		}
>>
>>   		/* Check if there already is a matching association on the
>>   		 * endpoint (other than the one created here).
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> Actually, I think you can remove that entire if statement (as well as some
> checks further down).  Looking at the net-next trees __sctp_connect, it appears
> that asoc is set to NULL at the top of the function, and not assigned to
> anything else until the call to sctp_association_new much farther down (line
> 1201).  That means the above if statement, as well as this:
>   if (asoc2 && asoc2 != asoc) {
> and this:
> if (!asoc) {
> will always be false, false, and true, respectively.

No, I don't think you can.  Consider a case of sctp_connectx() where 
each address specified in connectx has a different destination port.

First time through the loop, we'll create the association and set the 
peer.port.  The second time through the loop, we'll compare the that 
port to the port specified in the second address.  If the ports do not 
match, we need to stop.

-vlad
>
> Regards
> Neil
>

  reply	other threads:[~2013-04-03 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03 13:02 [PATCH -next] sctp: fix error return code in __sctp_connect() Wei Yongjun
2013-04-03 13:51 ` Neil Horman
2013-04-03 14:52   ` Vlad Yasevich [this message]
2013-04-03 14:59     ` Neil Horman
2013-04-03 14:52 ` Vlad Yasevich
2013-04-07 21:04 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=515C4220.6030802@gmail.com \
    --to=vyasevich@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=weiyj.lk@gmail.com \
    --cc=yongjun_wei@trendmicro.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).