* if the userland tools set things up wrong, this could be negative;
* just don't try to signal in this case
*/
- if (idx < 0)
+ if (idx < 0 || idx >= MAX_TAP_DEV)
return;
info = tapfds[idx];
- if ((idx < 0) || (idx > MAX_TAP_DEV) || !info)
+ if (!info)
return;
if (info->pid > 0) {
/* ctrl device, treat differently */
if (!idx)
return 0;
+ if (idx < 0 || idx >= MAX_TAP_DEV) {
+ WPRINTK("No device /dev/xen/blktap%d\n", idx);
+ return -ENODEV;
+ }
info = tapfds[idx];
-
- if ((idx < 0) || (idx > MAX_TAP_DEV) || !info) {
+ if (!info) {
WPRINTK("Unable to open device /dev/xen/blktap%d\n",
idx);
return -ENODEV;
unsigned long dev = arg;
unsigned long flags;
- info = tapfds[dev];
+ if (info || dev >= MAX_TAP_DEV)
+ return -EINVAL;
- if ((dev > MAX_TAP_DEV) || !info)
+ info = tapfds[dev];
+ if (!info)
return 0; /* should this be an error? */
spin_lock_irqsave(&pending_free_lock, flags);
return 0;
}
case BLKTAP_IOCTL_MINOR:
- {
- unsigned long dev = arg;
+ if (!info) {
+ unsigned long dev = arg;
- info = tapfds[dev];
+ if (dev >= MAX_TAP_DEV)
+ return -EINVAL;
- if ((dev > MAX_TAP_DEV) || !info)
- return -EINVAL;
+ info = tapfds[dev];
+ if (!info)
+ return -EINVAL;
+ }
return info->minor;
- }
+
case BLKTAP_IOCTL_MAJOR:
return blktap_major;
{
tap_blkif_t *info;
- info = tapfds[idx];
+ if (idx < 0 || idx >= MAX_TAP_DEV)
+ return;
- if ((idx < 0) || (idx > MAX_TAP_DEV) || !info)
+ info = tapfds[idx];
+ if (!info)
return;
wake_up_interruptible(&info->wait);
struct mm_struct *mm;
- info = tapfds[tapidx];
-
- if ((tapidx < 0) || (tapidx > MAX_TAP_DEV) || !info) {
+ if ((tapidx < 0) || (tapidx >= MAX_TAP_DEV)
+ || !(info = tapfds[tapidx])) {
WPRINTK("fast_flush: Couldn't get info!\n");
return;
}
rmb(); /* Ensure we see queued requests up to 'rp'. */
/*Check blkif has corresponding UE ring*/
- if (blkif->dev_num < 0) {
+ if (blkif->dev_num < 0 || blkif->dev_num >= MAX_TAP_DEV) {
/*oops*/
if (print_dbug) {
WPRINTK("Corresponding UE "
info = tapfds[blkif->dev_num];
- if (blkif->dev_num > MAX_TAP_DEV || !info ||
- !test_bit(0, &info->dev_inuse)) {
+ if (!info || !test_bit(0, &info->dev_inuse)) {
if (print_dbug) {
WPRINTK("Can't get UE info!\n");
print_dbug = 0;
struct mm_struct *mm;
struct vm_area_struct *vma = NULL;
- if (blkif->dev_num < 0 || blkif->dev_num > MAX_TAP_DEV)
+ if (blkif->dev_num < 0 || blkif->dev_num >= MAX_TAP_DEV)
goto fail_response;
info = tapfds[blkif->dev_num];
/* tapfds[0] is always NULL */
blktap_next_minor++;
- DPRINTK("Created misc_dev [/dev/xen/blktap%d]\n",i);
+ DPRINTK("Created misc_dev %d:0 [/dev/xen/blktap0]\n", ret);
/* Make sure the xen class exists */
if ((class = get_xen_class()) != NULL) {