if (n > OUTBUF_SZ) // check space in local buffer...
return U14ERR_NOOUT; // ...too many characters
if (copy_from_user(buffer, pData, n))
- return -ENOMEM; // could not copy
+ return -EFAULT;
buffer[n] = 0; // terminate for debug purposes
mutex_lock(&pdx->io_mutex); // Protect disconnect from new i/o
dev_dbg(&pdx->interface->dev,
"GetString read %d characters >%s<", nGot, buffer);
- copy_to_user(pUser, buffer, nCopyToUser);
-
- iReturn = nGot; // report characters read
+ if (copy_to_user(pUser, buffer, nCopyToUser))
+ iReturn = -EFAULT;
+ else
+ iReturn = nGot; // report characters read
} else
spin_unlock_irq(&pdx->charInLock);
{
int iReturn;
TRANSFERDESC td;
- copy_from_user(&td, pTD, sizeof(td));
+
+ if (copy_from_user(&td, pTD, sizeof(td)))
+ return -EFAULT;
+
mutex_lock(&pdx->io_mutex);
dev_dbg(&pdx->interface->dev, "%s area:%d, size:%08x", __func__,
td.wAreaNum, td.dwLength);
{
int iReturn = U14ERR_NOERROR;
TRANSFEREVENT te;
- copy_from_user(&te, pTE, sizeof(te)); // get a local copy of the data
+
+ // get a local copy of the data
+ if (copy_from_user(&te, pTE, sizeof(te)))
+ return -EFAULT;
+
if (te.wAreaNum >= MAX_TRANSAREAS) // the area must exist
return U14ERR_BADAREA;
else {
tx.entries[0].physical =
(long long)(tx.linear + pdx->StagedOffset);
tx.entries[0].size = tx.size;
- copy_to_user(pTX, &tx, sizeof(tx));
+
+ if (copy_to_user(pTX, &tx, sizeof(tx)))
+ iReturn = -EFAULT;
}
mutex_unlock(&pdx->io_mutex);
return iReturn;
}
mutex_unlock(&pdx->io_mutex);
- copy_to_user(pGST, &gst, sizeof(gst)); // copy result to user space
+ if (copy_to_user(pGST, &gst, sizeof(gst)))
+ return -EFAULT;
+
return iReturn;
}
{
int iReturn;
TDBGBLOCK db;
- copy_from_user(&db, pDB, sizeof(db)); // get the data
+
+ if (copy_from_user(&db, pDB, sizeof(db)))
+ return -EFAULT;
mutex_lock(&pdx->io_mutex);
dev_dbg(&pdx->interface->dev, "%s @ %08x", __func__, db.iAddr);
{
int iReturn;
TDBGBLOCK db;
- copy_from_user(&db, pDB, sizeof(db)); // get the data
+
+ if (copy_from_user(&db, pDB, sizeof(db)))
+ return -EFAULT;
mutex_lock(&pdx->io_mutex);
dev_dbg(&pdx->interface->dev, "%s @ %08x", __func__, db.iAddr);
{
int iReturn;
TDBGBLOCK db;
- copy_from_user(&db, pDB, sizeof(db)); // get the data
+
+ if (copy_from_user(&db, pDB, sizeof(db)))
+ return -EFAULT;
mutex_lock(&pdx->io_mutex);
dev_dbg(&pdx->interface->dev, "%s @ %08x", __func__, db.iAddr);
{
int iReturn;
TDBGBLOCK db;
- copy_from_user(&db, pDB, sizeof(db)); // get the data
+
+ if (copy_from_user(&db, pDB, sizeof(db)))
+ return -EFAULT;
mutex_lock(&pdx->io_mutex);
dev_dbg(&pdx->interface->dev, "%s", __func__);
DB_DATA, (D_TO_H | VENDOR | DEVREQ), 0, 0,
&db.iData, sizeof(db.iData), HZ);
if (iReturn == sizeof(db.iData)) {
- copy_to_user(pDB, &db, sizeof(db));
- iReturn = U14ERR_NOERROR;
+ if (copy_to_user(pDB, &db, sizeof(db)))
+ iReturn = -EFAULT;
+ else
+ iReturn = U14ERR_NOERROR;
} else
dev_err(&pdx->interface->dev, "%s failed, code %d", __func__,
iReturn);
int iReturn;
bool bToHost;
TRANSFERDESC td;
- copy_from_user(&td, pTD, sizeof(td));
+
+ if (copy_from_user(&td, pTD, sizeof(td)))
+ return -EFAULT;
+
mutex_lock(&pdx->io_mutex);
dev_dbg(&pdx->interface->dev, "%s area:%d, size:%08x", __func__,
td.wAreaNum, td.dwLength);
int iReturn = U14ERR_NOERROR;
unsigned int nArea;
TCIRCBLOCK cb;
+
dev_dbg(&pdx->interface->dev, "%s", __func__);
- copy_from_user(&cb, pCB, sizeof(cb));
+
+ if (copy_from_user(&cb, pCB, sizeof(cb)))
+ return -EFAULT;
+
mutex_lock(&pdx->io_mutex);
nArea = cb.nArea; // Retrieve parameters first
} else
iReturn = U14ERR_BADAREA;
- copy_to_user(pCB, &cb, sizeof(cb));
+ if (copy_to_user(pCB, &cb, sizeof(cb)))
+ iReturn = -EFAULT;
+
mutex_unlock(&pdx->io_mutex);
return iReturn;
}
int iReturn = U14ERR_NOERROR;
unsigned int nArea, uStart, uSize;
TCIRCBLOCK cb;
+
dev_dbg(&pdx->interface->dev, "%s", __func__);
- copy_from_user(&cb, pCB, sizeof(cb));
+
+ if (copy_from_user(&cb, pCB, sizeof(cb)))
+ return -EFAULT;
+
mutex_lock(&pdx->io_mutex);
nArea = cb.nArea; // Retrieve parameters first
} else
iReturn = U14ERR_BADAREA;
- copy_to_user(pCB, &cb, sizeof(cb));
+ if (copy_to_user(pCB, &cb, sizeof(cb)))
+ return -EFAULT;
+
mutex_unlock(&pdx->io_mutex);
return iReturn;
}