net: buf: Check we are not overflowing free buf count

Make sure the number of free bufs will never go over the
allocated limit. This is only used for debugging when printing
the free buf count so this is not very serious issue.

Change-Id: Icb5e34e969cbf07280c24966659addcf32829f7c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-04-05 09:54:51 +03:00
parent bf5d208f25
commit 04dc2fe4e1

View File

@ -80,7 +80,11 @@ static inline void inc_free_rx_bufs(struct net_buf *buf)
return;
}
num_free_rx_bufs++;
if (num_free_rx_bufs > IP_BUF_RX_SIZE) {
num_free_rx_bufs = IP_BUF_RX_SIZE;
} else {
num_free_rx_bufs++;
}
}
static inline void dec_free_tx_bufs(struct net_buf *buf)
@ -102,7 +106,11 @@ static inline void inc_free_tx_bufs(struct net_buf *buf)
return;
}
num_free_tx_bufs++;
if (num_free_tx_bufs > IP_BUF_TX_SIZE) {
num_free_tx_bufs = IP_BUF_TX_SIZE;
} else {
num_free_tx_bufs++;
}
}
static inline int get_frees(enum ip_buf_type type)