提交 7d0445d6 编写于 作者: M Michal Schmidt 提交者: David S. Miller

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: NMichal Schmidt <mschmidt@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 8e165e20
......@@ -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;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册