diff options
Diffstat (limited to 'lib/kfifo.c')
| -rw-r--r-- | lib/kfifo.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/kfifo.c b/lib/kfifo.c index 90ba1eb1..7638972c 100644 --- a/lib/kfifo.c +++ b/lib/kfifo.c @@ -62,6 +62,8 @@ int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, } fifo->mask = size - 1; + printk("%s-%d: fifo->data=%p\n", __func__, __LINE__, fifo->data); + return 0; } EXPORT_SYMBOL(__kfifo_alloc); @@ -114,6 +116,20 @@ static void kfifo_copy_in(struct __kfifo *fifo, const void *src, } l = min(len, size - off); + if (!src) + printk("%s: src NULL\n", __func__); + if (!(src + l)) + printk("%s: src+l (l=%d) NULL\n", __func__, l); + if (!fifo->data) { + printk("%s: fifo->data NULL\n", __func__); + return; + } + if (!(fifo->data + off)) { + printk("%s: fifo->data+off (off=%d) NULL\n", __func__, off); + return; + } + + memcpy(fifo->data + off, src, l); memcpy(fifo->data, src + l, len - l); /* @@ -132,6 +148,11 @@ unsigned int __kfifo_in(struct __kfifo *fifo, if (len > l) len = l; + if (!fifo->data) { + printk("%s-%d: fifo->data NULL\n", __func__, __LINE__); + return -ENOMEM; + } + kfifo_copy_in(fifo, buf, len, fifo->in); fifo->in += len; return len; |
