Skip to content

Commit a122170

Browse files
pietroborrellokuba-moo
authored andcommitted
sctp: sctp_sock_filter(): avoid list_entry() on possibly empty list
Use list_is_first() to check whether tsp->asoc matches the first element of ep->asocs, as the list is not guaranteed to have an entry. Fixes: 8f840e4 ("sctp: add the sctp_diag.c file") Signed-off-by: Pietro Borrello <[email protected]> Acked-by: Xin Long <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0ed577e commit a122170

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

net/sctp/diag.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,9 @@ static int sctp_sock_filter(struct sctp_endpoint *ep, struct sctp_transport *tsp
343343
struct sctp_comm_param *commp = p;
344344
struct sock *sk = ep->base.sk;
345345
const struct inet_diag_req_v2 *r = commp->r;
346-
struct sctp_association *assoc =
347-
list_entry(ep->asocs.next, struct sctp_association, asocs);
348346

349347
/* find the ep only once through the transports by this condition */
350-
if (tsp->asoc != assoc)
348+
if (!list_is_first(&tsp->asoc->asocs, &ep->asocs))
351349
return 0;
352350

353351
if (r->sdiag_family != AF_UNSPEC && sk->sk_family != r->sdiag_family)

0 commit comments

Comments
 (0)