]> err.no Git - linux-2.6/commit
IB/ehca: Fix clipping of device limits to INT_MAX
authorRoland Dreier <rolandd@cisco.com>
Wed, 10 Oct 2007 02:59:18 +0000 (19:59 -0700)
committerRoland Dreier <rolandd@cisco.com>
Wed, 10 Oct 2007 02:59:18 +0000 (19:59 -0700)
commit76dea3bc2644e99cce1d98d0bbd3124314e5b50a
tree14ffcb341294948c429274922cbe6a4bcedcf5bb
parentede6bc04f3a07a9c93f02c92cdc281d254398321
IB/ehca: Fix clipping of device limits to INT_MAX

Doing min_t(int, foo, INT_MAX) doesn't work correctly, because if foo
is bigger than INT_MAX, then when treated as a signed integer, it will
become negative and hence such an expression is just an elaborate NOP.

Fix such cases in ehca to do min_t(unsigned, foo, INT_MAX) instead.
This fixes negative reported values for max_cqe, max_pd and max_ah:

Before:

        max_cqe:                        -64
        max_pd:                         -1
        max_ah:                         -1

After:
        max_cqe:                        2147483647
        max_pd:                         2147483647
        max_ah:                         2147483647

Based on a bug report and fix from Anton Blanchard <anton@samba.org>.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/ehca/ehca_hca.c