netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: sctp: remove NULL check in sctp_assoc_update_retran_path
@ 2014-03-13 13:45 Daniel Borkmann
  2014-03-13 17:24 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Borkmann @ 2014-03-13 13:45 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-sctp, davej, dan.carpenter

This is basically just to let Coverity et al shut up. Remove an
unneeded NULL check in sctp_assoc_update_retran_path().

It is safe to remove it, because in sctp_assoc_update_retran_path()
we iterate over the list of transports, our own transport which is
asoc->peer.retran_path included. In the iteration, we skip the
list head element and transports in state SCTP_UNCONFIRMED.

Such transports came from peer addresses received in INIT/INIT-ACK
address parameters. They are not yet confirmed by a heartbeat and
not available for data transfers.

We know however that in the list of transports, even if it contains
such elements, it at least contains our asoc->peer.retran_path as
well, so even if next to that element, we only encounter
SCTP_UNCONFIRMED transports, we are always going to fall back to
asoc->peer.retran_path through sctp_trans_elect_best(), as that is
for sure not SCTP_UNCONFIRMED as per fbdf501c9374 ("sctp: Do no
select unconfirmed transports for retransmissions").

Whenever we call sctp_trans_elect_best() it will give us a non-NULL
element back, and therefore when we break out of the loop, we are
guaranteed to have a non-NULL transport pointer, and can remove
the NULL check.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
 net/sctp/associola.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index ee13d28..4f6d6f9 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1319,8 +1319,7 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
 			break;
 	}
 
-	if (trans_next != NULL)
-		asoc->peer.retran_path = trans_next;
+	asoc->peer.retran_path = trans_next;
 
 	pr_debug("%s: association:%p updated new path to addr:%pISpc\n",
 		 __func__, asoc, &asoc->peer.retran_path->ipaddr.sa);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: sctp: remove NULL check in sctp_assoc_update_retran_path
  2014-03-13 13:45 [PATCH net-next] net: sctp: remove NULL check in sctp_assoc_update_retran_path Daniel Borkmann
@ 2014-03-13 17:24 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-03-13 17:24 UTC (permalink / raw)
  To: dborkman; +Cc: netdev, linux-sctp, davej, dan.carpenter

From: Daniel Borkmann <dborkman@redhat.com>
Date: Thu, 13 Mar 2014 14:45:26 +0100

> This is basically just to let Coverity et al shut up. Remove an
> unneeded NULL check in sctp_assoc_update_retran_path().
> 
> It is safe to remove it, because in sctp_assoc_update_retran_path()
> we iterate over the list of transports, our own transport which is
> asoc->peer.retran_path included. In the iteration, we skip the
> list head element and transports in state SCTP_UNCONFIRMED.
> 
> Such transports came from peer addresses received in INIT/INIT-ACK
> address parameters. They are not yet confirmed by a heartbeat and
> not available for data transfers.
> 
> We know however that in the list of transports, even if it contains
> such elements, it at least contains our asoc->peer.retran_path as
> well, so even if next to that element, we only encounter
> SCTP_UNCONFIRMED transports, we are always going to fall back to
> asoc->peer.retran_path through sctp_trans_elect_best(), as that is
> for sure not SCTP_UNCONFIRMED as per fbdf501c9374 ("sctp: Do no
> select unconfirmed transports for retransmissions").
> 
> Whenever we call sctp_trans_elect_best() it will give us a non-NULL
> element back, and therefore when we break out of the loop, we are
> guaranteed to have a non-NULL transport pointer, and can remove
> the NULL check.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Reported-by: Dave Jones <davej@redhat.com>
> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>

Applied, thanks Daniel.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-13 17:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-13 13:45 [PATCH net-next] net: sctp: remove NULL check in sctp_assoc_update_retran_path Daniel Borkmann
2014-03-13 17:24 ` 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).