summaryrefslogtreecommitdiff
path: root/nuttx/drivers
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-03-13 07:21:06 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-03-13 07:21:06 -0600
commit8f1f3579e61e3fdbdc7fadfdbedf264c89dc4dca (patch)
tree714ecad73f67f764898afc1accdd1e0b903e1723 /nuttx/drivers
parent41bb6f24d5787d90ef47004a3c4d58de5974f000 (diff)
downloadpx4-nuttx-8f1f3579e61e3fdbdc7fadfdbedf264c89dc4dca.tar.gz
px4-nuttx-8f1f3579e61e3fdbdc7fadfdbedf264c89dc4dca.tar.bz2
px4-nuttx-8f1f3579e61e3fdbdc7fadfdbedf264c89dc4dca.zip
Pipes: Fix zero-lenth writes. From Jussi Kivilinna
Diffstat (limited to 'nuttx/drivers')
-rw-r--r--nuttx/drivers/pipes/pipe_common.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/nuttx/drivers/pipes/pipe_common.c b/nuttx/drivers/pipes/pipe_common.c
index 026c11ab5..b4cdfc2e2 100644
--- a/nuttx/drivers/pipes/pipe_common.c
+++ b/nuttx/drivers/pipes/pipe_common.c
@@ -384,6 +384,11 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len)
DEBUGASSERT(dev);
+ if (len == 0)
+ {
+ return 0;
+ }
+
/* Make sure that we have exclusive access to the device structure */
if (sem_wait(&dev->d_bfsem) < 0)
@@ -469,6 +474,11 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t
DEBUGASSERT(dev);
pipe_dumpbuffer("To PIPE:", (uint8_t*)buffer, len);
+ if (len == 0)
+ {
+ return 0;
+ }
+
/* At present, this method cannot be called from interrupt handlers. That is
* because it calls sem_wait (via pipecommon_semtake below) and sem_wait cannot
* be called from interrupt level. This actually happens fairly commonly