staging/rdma/hfi1: Return immediately on error
Now that the spinlock is not taken throughout hfi1_ioctl it is safe to return early rather than setting a variable and falling through the switch. Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
33ab349037
Коммит
2d1900f131
|
@ -1019,20 +1019,16 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
if (copy_from_user(&link_info,
|
if (copy_from_user(&link_info,
|
||||||
(struct hfi1_link_info __user *)arg,
|
(struct hfi1_link_info __user *)arg,
|
||||||
sizeof(link_info)))
|
sizeof(link_info)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
value = link_info.port_state;
|
value = link_info.port_state;
|
||||||
index = link_info.port_number;
|
index = link_info.port_number;
|
||||||
if (index > dd->num_pports - 1) {
|
if (index > dd->num_pports - 1)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ppd = &dd->pport[index];
|
ppd = &dd->pport[index];
|
||||||
if (!ppd) {
|
if (!ppd)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* What we want to transition to */
|
/* What we want to transition to */
|
||||||
phys_state = (value >> 4) & 0xF;
|
phys_state = (value >> 4) & 0xF;
|
||||||
|
@ -1056,8 +1052,7 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
dev_state = HLS_DN_DISABLE;
|
dev_state = HLS_DN_DISABLE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
ret = set_link_state(ppd, dev_state);
|
ret = set_link_state(ppd, dev_state);
|
||||||
break;
|
break;
|
||||||
|
@ -1072,8 +1067,7 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
send_idle_sma(dd, SMA_IDLE_ACTIVE);
|
send_idle_sma(dd, SMA_IDLE_ACTIVE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -1086,7 +1080,7 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
if (copy_from_user(&link_info,
|
if (copy_from_user(&link_info,
|
||||||
(struct hfi1_link_info __user *)arg,
|
(struct hfi1_link_info __user *)arg,
|
||||||
sizeof(link_info)))
|
sizeof(link_info)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
index = link_info.port_number;
|
index = link_info.port_number;
|
||||||
} else {
|
} else {
|
||||||
ret = __get_user(index, (int __user *)arg);
|
ret = __get_user(index, (int __user *)arg);
|
||||||
|
@ -1094,16 +1088,13 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index > dd->num_pports - 1) {
|
if (index > dd->num_pports - 1)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ppd = &dd->pport[index];
|
ppd = &dd->pport[index];
|
||||||
if (!ppd) {
|
if (!ppd)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
|
||||||
value = hfi1_ibphys_portstate(ppd);
|
value = hfi1_ibphys_portstate(ppd);
|
||||||
value <<= 4;
|
value <<= 4;
|
||||||
value |= driver_lstate(ppd);
|
value |= driver_lstate(ppd);
|
||||||
|
@ -1120,7 +1111,7 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
ppd->link_width_active;
|
ppd->link_width_active;
|
||||||
if (copy_to_user((struct hfi1_link_info __user *)arg,
|
if (copy_to_user((struct hfi1_link_info __user *)arg,
|
||||||
&link_info, sizeof(link_info)))
|
&link_info, sizeof(link_info)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
} else {
|
} else {
|
||||||
ret = __put_user(value, (int __user *)arg);
|
ret = __put_user(value, (int __user *)arg);
|
||||||
}
|
}
|
||||||
|
@ -1151,14 +1142,12 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
/* just copy command structure */
|
/* just copy command structure */
|
||||||
argp = (unsigned long *)arg;
|
argp = (unsigned long *)arg;
|
||||||
if (copy_from_user(&filter_cmd, (void __user *)argp,
|
if (copy_from_user(&filter_cmd, (void __user *)argp,
|
||||||
sizeof(filter_cmd))) {
|
sizeof(filter_cmd)))
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (filter_cmd.opcode >= HFI1_MAX_FILTERS) {
|
if (filter_cmd.opcode >= HFI1_MAX_FILTERS) {
|
||||||
pr_alert("Invalid opcode in request\n");
|
pr_alert("Invalid opcode in request\n");
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snoop_dbg("Opcode %d Len %d Ptr %p",
|
snoop_dbg("Opcode %d Len %d Ptr %p",
|
||||||
|
@ -1167,17 +1156,15 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
|
|
||||||
filter_value = kcalloc(filter_cmd.length, sizeof(u8),
|
filter_value = kcalloc(filter_cmd.length, sizeof(u8),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!filter_value) {
|
if (!filter_value)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* copy remaining data from userspace */
|
/* copy remaining data from userspace */
|
||||||
if (copy_from_user((u8 *)filter_value,
|
if (copy_from_user((u8 *)filter_value,
|
||||||
(void __user *)filter_cmd.value_ptr,
|
(void __user *)filter_cmd.value_ptr,
|
||||||
filter_cmd.length)) {
|
filter_cmd.length)) {
|
||||||
kfree(filter_value);
|
kfree(filter_value);
|
||||||
ret = -EFAULT;
|
return -EFAULT;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
/* Drain packets first */
|
/* Drain packets first */
|
||||||
spin_lock_irqsave(&dd->hfi1_snoop.snoop_lock, flags);
|
spin_lock_irqsave(&dd->hfi1_snoop.snoop_lock, flags);
|
||||||
|
@ -1207,10 +1194,9 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||||
snoop_flags |= SNOOP_USE_METADATA;
|
snoop_flags |= SNOOP_USE_METADATA;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -ENOTTY;
|
return -ENOTTY;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
done:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче