aboutsummaryrefslogtreecommitdiff
path: root/lib/kfifo.c
diff options
context:
space:
mode:
authorwzedlare <vedatak01@gmail.com>2017-06-18 16:38:26 +0000
committerwzedlare <vedatak01@gmail.com>2017-06-19 16:57:11 +0000
commitc7d4e3fd588e3ba3d3fa4d5cfa224aa54bc288bf (patch)
treeb8b64cb9deb6832c1e41f58f0f143514beafc709 /lib/kfifo.c
parent28c99c87b881bb664c44bb26e80a681f87d54e60 (diff)
p2a42: Import fully working kernel sourceHEADn7.1
Change-Id: Ia4c94f09e29843b1af34d466243378a357e97b70
Diffstat (limited to 'lib/kfifo.c')
-rw-r--r--lib/kfifo.c21
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;