aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/motor/tspdrv.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/motor/tspdrv.c')
-rw-r--r--drivers/motor/tspdrv.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/motor/tspdrv.c b/drivers/motor/tspdrv.c
index 73cb2772edb..b22bb0534c2 100644
--- a/drivers/motor/tspdrv.c
+++ b/drivers/motor/tspdrv.c
@@ -380,6 +380,12 @@ static ssize_t write(struct file *file, const char *buf, size_t count,
return 0;
}
+ /* Check buffer size */
+ if ((count <= SPI_HEADER_SIZE) || (count > SPI_BUFFER_SIZE)) {
+ DbgOut((KERN_ERR "tspdrv: invalid write buffer size.\n"));
+ return 0;
+ }
+
/* Copy immediately the input buffer */
if (0 != copy_from_user(g_cWriteBuffer, buf, count)) {
/* Failed to copy all the data, exit */
@@ -387,12 +393,6 @@ static ssize_t write(struct file *file, const char *buf, size_t count,
return 0;
}
- /* Check buffer size */
- if ((count <= SPI_HEADER_SIZE) || (count > SPI_BUFFER_SIZE)) {
- DbgOut((KERN_ERR "tspdrv: invalid write buffer size.\n"));
- return 0;
- }
-
while (i < count) {
int nIndexFreeBuffer; /* initialized below */