Skip to content

Commit 3eaf408

Browse files
David LaightKernel Patches Daemon
authored andcommitted
net/mptcp: Change some dubious min_t(int, ...) to min()
There are two: min_t(int, xxx, mptcp_wnd_end(msk) - msk->snd_nxt); Both mptcp_wnd_end(msk) and msk->snd_nxt are u64, their difference (aka the window size) might be limited to 32 bits - but that isn't knowable from this code. So checks being added to min_t() detect the potential discard of significant bits. Provided the 'avail_size' and return of mptcp_check_allowed_size() are changed to an unsigned type (size_t matches the type the caller uses) both min_t() can be changed to min(). Signed-off-by: David Laight <[email protected]>
1 parent 1ce101e commit 3eaf408

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/mptcp/protocol.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,8 @@ struct mptcp_sendmsg_info {
11251125
bool data_lock_held;
11261126
};
11271127

1128-
static int mptcp_check_allowed_size(const struct mptcp_sock *msk, struct sock *ssk,
1129-
u64 data_seq, int avail_size)
1128+
static size_t mptcp_check_allowed_size(const struct mptcp_sock *msk, struct sock *ssk,
1129+
u64 data_seq, size_t avail_size)
11301130
{
11311131
u64 window_end = mptcp_wnd_end(msk);
11321132
u64 mptcp_snd_wnd;
@@ -1135,7 +1135,7 @@ static int mptcp_check_allowed_size(const struct mptcp_sock *msk, struct sock *s
11351135
return avail_size;
11361136

11371137
mptcp_snd_wnd = window_end - data_seq;
1138-
avail_size = min_t(unsigned int, mptcp_snd_wnd, avail_size);
1138+
avail_size = min(mptcp_snd_wnd, avail_size);
11391139

11401140
if (unlikely(tcp_sk(ssk)->snd_wnd < mptcp_snd_wnd)) {
11411141
tcp_sk(ssk)->snd_wnd = min_t(u64, U32_MAX, mptcp_snd_wnd);
@@ -1479,7 +1479,7 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
14791479
if (!ssk || !sk_stream_memory_free(ssk))
14801480
return NULL;
14811481

1482-
burst = min_t(int, MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt);
1482+
burst = min(MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt);
14831483
wmem = READ_ONCE(ssk->sk_wmem_queued);
14841484
if (!burst)
14851485
return ssk;

0 commit comments

Comments
 (0)