* [PATCH -next] sctp: fix error return code in __sctp_connect() @ 2013-04-03 13:02 Wei Yongjun 2013-04-03 13:51 ` Neil Horman ` (3 more replies) 0 siblings, 4 replies; 10+ messages in thread From: Wei Yongjun @ 2013-04-03 13:02 UTC (permalink / raw) To: vyasevich, sri, nhorman, davem; +Cc: yongjun_wei, linux-sctp, netdev 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). ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in __sctp_connect() 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 2013-04-03 14:52 ` Vlad Yasevich ` (2 subsequent siblings) 3 siblings, 1 reply; 10+ messages in thread From: Neil Horman @ 2013-04-03 13:51 UTC (permalink / raw) To: Wei Yongjun; +Cc: vyasevich, sri, davem, yongjun_wei, linux-sctp, netdev 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. Regards Neil ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in __sctp_connect() 2013-04-03 13:51 ` Neil Horman @ 2013-04-03 14:52 ` Vlad Yasevich 2013-04-03 14:59 ` Neil Horman 0 siblings, 1 reply; 10+ messages in thread From: Vlad Yasevich @ 2013-04-03 14:52 UTC (permalink / raw) To: Neil Horman; +Cc: Wei Yongjun, davem, yongjun_wei, linux-sctp, netdev 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 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in __sctp_connect() 2013-04-03 14:52 ` Vlad Yasevich @ 2013-04-03 14:59 ` Neil Horman 0 siblings, 0 replies; 10+ messages in thread From: Neil Horman @ 2013-04-03 14:59 UTC (permalink / raw) To: Vlad Yasevich; +Cc: Wei Yongjun, davem, yongjun_wei, linux-sctp, netdev On Wed, Apr 03, 2013 at 10:52:16AM -0400, Vlad Yasevich wrote: > 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 Ah, you're right, I missed the while loop, apologies Acked-by: Neil Horman <nhorman@tuxdriver.com> > > > >Regards > >Neil > > > > -- > 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 > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in __sctp_connect() 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 2013-04-07 21:04 ` David Miller 2016-06-13 15:08 ` [PATCH -next] sctp: fix error return code in sctp_init() weiyj_lk 3 siblings, 0 replies; 10+ messages in thread From: Vlad Yasevich @ 2013-04-03 14:52 UTC (permalink / raw) To: Wei Yongjun; +Cc: sri, nhorman, davem, yongjun_wei, linux-sctp, netdev On 04/03/2013 09:02 AM, 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> Acked-by: Vlad Yasevich <vyasevich@gmail.com> -vlad > --- > 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). > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in __sctp_connect() 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 @ 2013-04-07 21:04 ` David Miller 2016-06-13 15:08 ` [PATCH -next] sctp: fix error return code in sctp_init() weiyj_lk 3 siblings, 0 replies; 10+ messages in thread From: David Miller @ 2013-04-07 21:04 UTC (permalink / raw) To: weiyj.lk; +Cc: vyasevich, sri, nhorman, yongjun_wei, linux-sctp, netdev From: Wei Yongjun <weiyj.lk@gmail.com> Date: Wed, 3 Apr 2013 21:02:28 +0800 > 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> Applied. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH -next] sctp: fix error return code in sctp_init() 2013-04-03 13:02 [PATCH -next] sctp: fix error return code in __sctp_connect() Wei Yongjun ` (2 preceding siblings ...) 2013-04-07 21:04 ` David Miller @ 2016-06-13 15:08 ` weiyj_lk 2016-06-14 3:04 ` Xin Long 2016-06-15 6:46 ` David Miller 3 siblings, 2 replies; 10+ messages in thread From: weiyj_lk @ 2016-06-13 15:08 UTC (permalink / raw) To: Vlad Yasevich, Neil Horman, David S. Miller Cc: Wei Yongjun, linux-sctp, netdev From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> --- net/sctp/protocol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 40022ee..3b56ae5 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -1479,7 +1479,8 @@ static __init int sctp_init(void) INIT_HLIST_HEAD(&sctp_port_hashtable[i].chain); } - if (sctp_transport_hashtable_init()) + status = sctp_transport_hashtable_init(); + if (status) goto err_thash_alloc; pr_info("Hash tables configured (bind %d/%d)\n", sctp_port_hashsize, ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in sctp_init() 2016-06-13 15:08 ` [PATCH -next] sctp: fix error return code in sctp_init() weiyj_lk @ 2016-06-14 3:04 ` Xin Long 2016-06-14 13:21 ` Neil Horman 2016-06-15 6:46 ` David Miller 1 sibling, 1 reply; 10+ messages in thread From: Xin Long @ 2016-06-14 3:04 UTC (permalink / raw) To: weiyj_lk Cc: Vlad Yasevich, Neil Horman, David S. Miller, Wei Yongjun, linux-sctp, network dev On Mon, Jun 13, 2016 at 11:08 PM, <weiyj_lk@163.com> 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 done elsewhere in this function. > > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> > --- > net/sctp/protocol.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c > index 40022ee..3b56ae5 100644 > --- a/net/sctp/protocol.c > +++ b/net/sctp/protocol.c > @@ -1479,7 +1479,8 @@ static __init int sctp_init(void) > INIT_HLIST_HEAD(&sctp_port_hashtable[i].chain); > } > > - if (sctp_transport_hashtable_init()) > + status = sctp_transport_hashtable_init(); > + if (status) > goto err_thash_alloc; > > pr_info("Hash tables configured (bind %d/%d)\n", sctp_port_hashsize, > > Acked-by: Xin Long <lucien.xin@gmail.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in sctp_init() 2016-06-14 3:04 ` Xin Long @ 2016-06-14 13:21 ` Neil Horman 0 siblings, 0 replies; 10+ messages in thread From: Neil Horman @ 2016-06-14 13:21 UTC (permalink / raw) To: Xin Long Cc: weiyj_lk, Vlad Yasevich, David S. Miller, Wei Yongjun, linux-sctp, network dev On Tue, Jun 14, 2016 at 11:04:05AM +0800, Xin Long wrote: > On Mon, Jun 13, 2016 at 11:08 PM, <weiyj_lk@163.com> 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 done elsewhere in this function. > > > > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> > > --- > > net/sctp/protocol.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c > > index 40022ee..3b56ae5 100644 > > --- a/net/sctp/protocol.c > > +++ b/net/sctp/protocol.c > > @@ -1479,7 +1479,8 @@ static __init int sctp_init(void) > > INIT_HLIST_HEAD(&sctp_port_hashtable[i].chain); > > } > > > > - if (sctp_transport_hashtable_init()) > > + status = sctp_transport_hashtable_init(); > > + if (status) > > goto err_thash_alloc; > > > > pr_info("Hash tables configured (bind %d/%d)\n", sctp_port_hashsize, > > > > > Acked-by: Xin Long <lucien.xin@gmail.com> > -- > 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 Acked-by: Neil Horman <nhorman@tuxdriver.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH -next] sctp: fix error return code in sctp_init() 2016-06-13 15:08 ` [PATCH -next] sctp: fix error return code in sctp_init() weiyj_lk 2016-06-14 3:04 ` Xin Long @ 2016-06-15 6:46 ` David Miller 1 sibling, 0 replies; 10+ messages in thread From: David Miller @ 2016-06-15 6:46 UTC (permalink / raw) To: weiyj_lk; +Cc: vyasevich, nhorman, yongjun_wei, linux-sctp, netdev From: weiyj_lk@163.com Date: Mon, 13 Jun 2016 23:08:26 +0800 > From: Wei Yongjun <yongjun_wei@trendmicro.com.cn> > > Fix to return a negative error code from the error handling > case instead of 0, as done elsewhere in this function. > > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Applied. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-06-15 6:46 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2013-04-03 14:59 ` Neil Horman 2013-04-03 14:52 ` Vlad Yasevich 2013-04-07 21:04 ` David Miller 2016-06-13 15:08 ` [PATCH -next] sctp: fix error return code in sctp_init() weiyj_lk 2016-06-14 3:04 ` Xin Long 2016-06-14 13:21 ` Neil Horman 2016-06-15 6:46 ` David Miller
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).