diff options
| author | Pietro Borrello <borrello@diag.uniroma1.it> | 2023-02-09 12:13:05 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-22 12:55:57 +0100 |
| commit | 747a17e25aecb4ea8a66427058e0d2d2a25046ad (patch) | |
| tree | 80305ea0cd7c0e741563d3c3a24ed9c591d425ba | |
| parent | a5c51e0c3202820192db3f3809e072f3ca2b1177 (diff) | |
| download | linux-747a17e25aecb4ea8a66427058e0d2d2a25046ad.tar.gz linux-747a17e25aecb4ea8a66427058e0d2d2a25046ad.tar.bz2 linux-747a17e25aecb4ea8a66427058e0d2d2a25046ad.zip | |
sctp: sctp_sock_filter(): avoid list_entry() on possibly empty list
commit a1221703a0f75a9d81748c516457e0fc76951496 upstream.
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: 8f840e47f190 ("sctp: add the sctp_diag.c file")
Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://lore.kernel.org/r/20230208-sctp-filter-v2-1-6e1f4017f326@diag.uniroma1.it
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | net/sctp/diag.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/net/sctp/diag.c b/net/sctp/diag.c index 68ff82ff49a3..07d0ada23bfd 100644 --- a/net/sctp/diag.c +++ b/net/sctp/diag.c @@ -349,11 +349,9 @@ static int sctp_sock_filter(struct sctp_endpoint *ep, struct sctp_transport *tsp struct sctp_comm_param *commp = p; struct sock *sk = ep->base.sk; const struct inet_diag_req_v2 *r = commp->r; - struct sctp_association *assoc = - list_entry(ep->asocs.next, struct sctp_association, asocs); /* find the ep only once through the transports by this condition */ - if (tsp->asoc != assoc) + if (!list_is_first(&tsp->asoc->asocs, &ep->asocs)) return 0; if (r->sdiag_family != AF_UNSPEC && sk->sk_family != r->sdiag_family) |
