linux/drivers/infiniband/hw/mlx4
Tejun Heo e8c8d1bc06 idr: remove MAX_IDR_MASK and move left MAX_IDR_* into idr.c
MAX_IDR_MASK is another weirdness in the idr interface.  As idr covers
whole positive integer range, it's defined as 0x7fffffff or INT_MAX.

Its usage in idr_find(), idr_replace() and idr_remove() is bizarre.
They basically mask off the sign bit and operate on the rest, so if
the caller, by accident, passes in a negative number, the sign bit
will be masked off and the remaining part will be used as if that was
the input, which is worse than crashing.

The constant is visible in idr.h and there are several users in the
kernel.

* drivers/i2c/i2c-core.c:i2c_add_numbered_adapter()

  Basically used to test if adap->nr is a negative number which isn't
  -1 and returns -EINVAL if so.  idr_alloc() already has negative
  @start checking (w/ WARN_ON_ONCE), so this can go away.

* drivers/infiniband/core/cm.c:cm_alloc_id()
  drivers/infiniband/hw/mlx4/cm.c:id_map_alloc()

  Used to wrap cyclic @start.  Can be replaced with max(next, 0).
  Note that this type of cyclic allocation using idr is buggy.  These
  are prone to spurious -ENOSPC failure after the first wraparound.

* fs/super.c:get_anon_bdev()

  The ID allocated from ida is masked off before being tested whether
  it's inside valid range.  ida allocated ID can never be a negative
  number and the masking is unnecessary.

Update idr_*() functions to fail with -EINVAL when negative @id is
specified and update other MAX_IDR_MASK users as described above.

This leaves MAX_IDR_MASK without any user, remove it and relocate
other MAX_IDR_* constants to lib/idr.c.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Roland Dreier <roland@kernel.org>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: "Marciniszyn, Mike" <mike.marciniszyn@intel.com>
Cc: Jack Morgenstein <jackm@dev.mellanox.co.il>
Cc: Or Gerlitz <ogerlitz@mellanox.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Wolfram Sang <wolfram@the-dreams.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-27 19:10:20 -08:00
..
Kconfig mlx4: Fix infiniband Kconfig dependencies. 2011-08-11 23:05:05 -07:00
Makefile IB/mlx4: Add iov directory in sysfs under the ib device 2012-09-30 20:33:39 -07:00
ah.c IB/mlx4: Fix SL to 802.1Q priority-bits mapping for IBoE 2012-01-03 21:00:02 -08:00
alias_GUID.c IB/mlx4: Fix build error on platforms where UL is not 64 bits 2012-10-18 10:29:01 -07:00
cm.c idr: remove MAX_IDR_MASK and move left MAX_IDR_* into idr.c 2013-02-27 19:10:20 -08:00
cq.c mlx4: 64-byte CQE/EQE support 2012-11-26 10:19:17 -08:00
doorbell.c IB: expand ib_umem_get() prototype 2008-04-29 08:06:12 -07:00
mad.c IB/mlx4: Fix bug unwinding on error in mlx4_ib_init_sriov() 2013-02-15 15:22:26 -08:00
main.c IB/mlx4: Advertise MW support 2013-02-25 10:44:32 -08:00
mcg.c IB/mlx4: Synchronize cleanup of MCGs in MCG paravirtualization 2012-10-18 10:29:02 -07:00
mlx4_ib.h IB/mlx4: Support memory window binding 2013-02-25 10:44:32 -08:00
mr.c IB/mlx4: Support memory window binding 2013-02-25 10:44:32 -08:00
qp.c IB/mlx4: Support memory window binding 2013-02-25 10:44:32 -08:00
srq.c IB/mlx4: Replace printk(KERN_yyy...) with pr_yyy(...) 2012-05-08 11:59:36 -07:00
sysfs.c IB/mlx4: Adjust duplicate test 2013-02-15 15:23:26 -08:00
user.h mlx4: 64-byte CQE/EQE support 2012-11-26 10:19:17 -08:00