mirror of
https://github.com/torvalds/linux.git
synced 2026-02-04 15:28:49 +08:00
staging/rdma/hfi1: Reduce snoop locking scope in IOCTL handler.
This patch avoids issues while calling into copy from/to user while holding the lock by only taking the lock when it is absolutely required. The only commands which require the snoop lock are: *Set Filter *Clear Filter *Clear Queue 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:
committed by
Greg Kroah-Hartman
parent
f1811cf632
commit
33ab349037
@@ -1012,8 +1012,6 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||
*/
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock_irqsave(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
|
||||
switch (cmd) {
|
||||
case HFI1_SNOOP_IOCSETLINKSTATE_EXTRA:
|
||||
memset(&link_info, 0, sizeof(link_info));
|
||||
@@ -1130,11 +1128,14 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||
|
||||
case HFI1_SNOOP_IOCCLEARQUEUE:
|
||||
snoop_dbg("Clearing snoop queue");
|
||||
spin_lock_irqsave(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
drain_snoop_list(&dd->hfi1_snoop.queue);
|
||||
spin_unlock_irqrestore(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
break;
|
||||
|
||||
case HFI1_SNOOP_IOCCLEARFILTER:
|
||||
snoop_dbg("Clearing filter");
|
||||
spin_lock_irqsave(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
if (dd->hfi1_snoop.filter_callback) {
|
||||
/* Drain packets first */
|
||||
drain_snoop_list(&dd->hfi1_snoop.queue);
|
||||
@@ -1142,6 +1143,7 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||
}
|
||||
kfree(dd->hfi1_snoop.filter_value);
|
||||
dd->hfi1_snoop.filter_value = NULL;
|
||||
spin_unlock_irqrestore(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
break;
|
||||
|
||||
case HFI1_SNOOP_IOCSETFILTER:
|
||||
@@ -1178,13 +1180,14 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||
break;
|
||||
}
|
||||
/* Drain packets first */
|
||||
spin_lock_irqsave(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
drain_snoop_list(&dd->hfi1_snoop.queue);
|
||||
dd->hfi1_snoop.filter_callback =
|
||||
hfi1_filters[filter_cmd.opcode].filter;
|
||||
/* just in case we see back to back sets */
|
||||
kfree(dd->hfi1_snoop.filter_value);
|
||||
dd->hfi1_snoop.filter_value = filter_value;
|
||||
|
||||
spin_unlock_irqrestore(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
break;
|
||||
case HFI1_SNOOP_IOCGETVERSION:
|
||||
value = SNOOP_CAPTURE_VERSION;
|
||||
@@ -1208,7 +1211,6 @@ static long hfi1_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
|
||||
break;
|
||||
}
|
||||
done:
|
||||
spin_unlock_irqrestore(&dd->hfi1_snoop.snoop_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user