Re: [PATCH net v3] sctp: socket: remove unused 'err' parameter from sctp_skb_recv_datagram
From: Xin Long
Date: Mon Jul 20 2026 - 12:30:25 EST
On Fri, Jul 17, 2026 at 2:19 PM David Laight
<david.laight.linux@xxxxxxxxx> wrote:
>
> On Fri, 17 Jul 2026 11:10:21 -0400
> Xin Long <lucien.xin@xxxxxxxxx> wrote:
>
> > On Fri, Jul 17, 2026 at 4:21 AM luoqing <l1138897701@xxxxxxx> wrote:
> > >
> > > From: luoqing <luoqing@xxxxxxxxxx>
> > >
> > > The 'err' parameter in sctp_skb_recv_datagram() is never used by any
> > > of its callers. Both sctp_recvmsg() and sctp_ulpevent_read_nxtinfo()
> > > pass the address of a local variable but never check its value after
> > > the function returns, rendering the parameter completely useless.
> > >
> > > Remove the unused parameter to simplify the function signature and
> > > eliminate dead code.
> > >
> > > Signed-off-by: luoqing <luoqing@xxxxxxxxxx>
> > > ---
> > > include/net/sctp/sctp.h | 2 +-
> > > net/sctp/socket.c | 10 +++-------
> > > net/sctp/ulpevent.c | 3 +--
> > > 3 files changed, 5 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
> > > index d50c27812504..b86d50d6b146 100644
> > > --- a/include/net/sctp/sctp.h
> > > +++ b/include/net/sctp/sctp.h
> > > @@ -97,7 +97,7 @@ void sctp_sock_rfree(struct sk_buff *skb);
> > >
> > > extern struct percpu_counter sctp_sockets_allocated;
> > > int sctp_asconf_mgmt(struct sctp_sock *, struct sctp_sockaddr_entry *);
> > > -struct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int *);
> > > +struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags);
> > >
> > > typedef int (*sctp_callback_t)(struct sctp_endpoint *, struct sctp_transport *, void *);
> > > void sctp_transport_walk_start(struct rhashtable_iter *iter);
> > > diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> > > index c7b9e325ec1c..3804382d78e0 100644
> > > --- a/net/sctp/socket.c
> > > +++ b/net/sctp/socket.c
> > > @@ -2123,7 +2123,7 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
> > > goto out;
> > > }
> > >
> > > - skb = sctp_skb_recv_datagram(sk, flags, &err);
> > > + skb = sctp_skb_recv_datagram(sk, flags);
> > > if (!skb)
> > > goto out;
> > >
> > > @@ -9082,7 +9082,7 @@ static int sctp_wait_for_packet(struct sock *sk, int *err, long *timeo_p)
> > > * Note: This is pretty much the same routine as in core/datagram.c
> > > * with a few changes to make lksctp work.
> > > */
> > > -struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int *err)
> > > +struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags)
> > > {
> > > int error;
> > > struct sk_buff *skb;
> > > @@ -9120,17 +9120,13 @@ struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int *err)
> > > if (sk->sk_shutdown & RCV_SHUTDOWN)
> > > break;
> > >
> > > -
> > > /* User doesn't want to wait. */
> > > error = -EAGAIN;
> > > if (!timeo)
> > > goto no_packet;
> > > - } while (sctp_wait_for_packet(sk, err, &timeo) == 0);
> > > -
> > > - return NULL;
> > > + } while (sctp_wait_for_packet(sk, &error, &timeo) == 0);
> > >
> > > no_packet:
> > > - *err = error;
> > > return NULL;
> > > }
> > >
> > > diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
> > > index 8920ca92a011..8ed51a15c3a4 100644
> > > --- a/net/sctp/ulpevent.c
> > > +++ b/net/sctp/ulpevent.c
> > > @@ -1061,9 +1061,8 @@ void sctp_ulpevent_read_nxtinfo(const struct sctp_ulpevent *event,
> > > struct sock *sk)
> > > {
> > > struct sk_buff *skb;
> > > - int err;
> > >
> > > - skb = sctp_skb_recv_datagram(sk, MSG_PEEK | MSG_DONTWAIT, &err);
> > > + skb = sctp_skb_recv_datagram(sk, MSG_PEEK | MSG_DONTWAIT);
> > > if (skb != NULL) {
> > > __sctp_ulpevent_read_nxtinfo(sctp_skb2event(skb),
> > > msghdr, skb);
> > > --
> > > 2.25.1
> > >
> > I think it's used at [1] in sctp_recvmsg():
> >
> > skb = sctp_skb_recv_datagram(sk, flags, &err);
> > if (!skb)
> > goto out;
>
> Would it make more sense to ERR_PTR() etc ?
>
Let's keep consistent with skb_recv_datagram() where it's &err,
besides, there's a shutdown condition (returns 0 via err param).
Thanks.