diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-02-25 15:04:24 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-26 20:27:50 (GMT) |
commit | 7d0445d66a7619e23257570daa794dbf1d89c2a6 (patch) | |
tree | 0b407352012532ea4382f7919298b7fb3a866f64 /drivers | |
parent | 8e165e20348b53583f6c6cb45865b89209f4aa13 (diff) | |
download | linux-7d0445d66a7619e23257570daa794dbf1d89c2a6.tar.xz |
bnx2x: clamp num_queues to prevent passing a negative value
Use the clamp() macro to make the calculation of the number of queues
slightly easier to understand. It also avoids a crash when someone
accidentally passes a negative value in num_queues= module parameter.
Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 89d75c2..34d1249 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -61,10 +61,9 @@ static void bnx2x_add_all_napi(struct bnx2x *bp) static int bnx2x_calc_num_queues(struct bnx2x *bp) { - return bnx2x_num_queues ? - min_t(int, bnx2x_num_queues, BNX2X_MAX_QUEUES(bp)) : - min_t(int, netif_get_num_default_rss_queues(), - BNX2X_MAX_QUEUES(bp)); + int nq = bnx2x_num_queues ? : netif_get_num_default_rss_queues(); + nq = clamp(nq, 1, BNX2X_MAX_QUEUES(bp)); + return nq; } /** |