On Wed, Mar 02, 2022 at 10:27:53AM +0800, Wang Yufen wrote: > diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c > index 9b9b02052fd3..ac9f491cc139 100644 > --- a/net/ipv4/tcp_bpf.c > +++ b/net/ipv4/tcp_bpf.c > @@ -421,8 +421,10 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) > osize = msg_tx->sg.size; > err = sk_msg_alloc(sk, msg_tx, msg_tx->sg.size + copy, msg_tx->sg.end - 1); > if (err) { > - if (err != -ENOSPC) > + if (err != -ENOSPC) { > + sk_msg_trim(sk, msg_tx, osize); > goto wait_for_memory; Is it a good idea to handle this logic inside sk_msg_alloc()?