In net/rds/recv.c, ensure incoming RDS message references (rds_inc_put) and socket receive queue bounds are properly balanced when handling error or truncated incoming frames. Fixes: bdbe6fbc6a2f ("RDS: recv.c") Assisted-by: LLM Signed-off-by: Hui Peng --- diff --git a/net/rds/recv.c b/net/rds/recv.c index 6204e577a90a..0743706af8ca 100644 --- a/net/rds/recv.c +++ b/net/rds/recv.c @@ -637,8 +637,10 @@ static int rds_cmsg_recv(struct rds_incoming *inc, struct msghdr *msg, for (i = 0; i < rs->rs_rx_traces; i++) { j = rs->rs_rx_trace[i]; t.rx_trace_pos[i] = j; - t.rx_trace[i] = inc->i_rx_lat_trace[j + 1] - - inc->i_rx_lat_trace[j]; + if (inc->i_rx_lat_trace[j + 1] && + inc->i_rx_lat_trace[j]) + t.rx_trace[i] = inc->i_rx_lat_trace[j + 1] - + inc->i_rx_lat_trace[j]; } ret = put_cmsg(msg, SOL_RDS, RDS_CMSG_RXPATH_LATENCY,