[ofa-general] [PATCH 01/20] IB/ipath - Allow old and new diagnostic packet formats

Ralph Campbell ralph.campbell at qlogic.com
Wed Apr 2 15:49:06 PDT 2008


From: Michael Albaugh <Michael.Albaugh at Qlogic.com>

This patch checks for old and new format writes to send a
packet via the diagnostic interface.

Signed-off-by: Michael Albaugh <Michael.Albaugh at Qlogic.com>
---

 drivers/infiniband/hw/ipath/ipath_diag.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index af59bf3..c9bfd82 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -332,12 +332,17 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
 	u64 val;
 	u32 l_state, lt_state; /* LinkState, LinkTrainingState */
 
-	if (count != sizeof(dp)) {
+	if (count < sizeof(odp)) {
 		ret = -EINVAL;
 		goto bail;
 	}
 
-	if (copy_from_user(&dp, data, sizeof(dp))) {
+	if (count == sizeof(dp)) {
+		if (copy_from_user(&dp, data, sizeof(dp))) {
+			ret = -EFAULT;
+			goto bail;
+		}
+	} else if (copy_from_user(&odp, data, sizeof(odp))) {
 		ret = -EFAULT;
 		goto bail;
 	}




More information about the general mailing list