Commit 59d40dd9 authored by Carol L Soto's avatar Carol L Soto Committed by Doug Ledford

IB/ucm: Fix bitmap wrap when devnum > IB_UCM_MAX_DEVICES

ib_ucm_release_dev clears the wrong bit if devnum is greater
than IB_UCM_MAX_DEVICES.
Signed-off-by: default avatarCarol L Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 8b7cce0d
...@@ -1193,6 +1193,7 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) ...@@ -1193,6 +1193,7 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
return 0; return 0;
} }
static DECLARE_BITMAP(overflow_map, IB_UCM_MAX_DEVICES);
static void ib_ucm_release_dev(struct device *dev) static void ib_ucm_release_dev(struct device *dev)
{ {
struct ib_ucm_device *ucm_dev; struct ib_ucm_device *ucm_dev;
...@@ -1202,7 +1203,7 @@ static void ib_ucm_release_dev(struct device *dev) ...@@ -1202,7 +1203,7 @@ static void ib_ucm_release_dev(struct device *dev)
if (ucm_dev->devnum < IB_UCM_MAX_DEVICES) if (ucm_dev->devnum < IB_UCM_MAX_DEVICES)
clear_bit(ucm_dev->devnum, dev_map); clear_bit(ucm_dev->devnum, dev_map);
else else
clear_bit(ucm_dev->devnum - IB_UCM_MAX_DEVICES, dev_map); clear_bit(ucm_dev->devnum - IB_UCM_MAX_DEVICES, overflow_map);
kfree(ucm_dev); kfree(ucm_dev);
} }
...@@ -1226,7 +1227,6 @@ static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, ...@@ -1226,7 +1227,6 @@ static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
static dev_t overflow_maj; static dev_t overflow_maj;
static DECLARE_BITMAP(overflow_map, IB_UCM_MAX_DEVICES);
static int find_overflow_devnum(void) static int find_overflow_devnum(void)
{ {
int ret; int ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment