[PATCH 1/9] kfifo: allow to pass a null point on kfifo_free

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Tue Dec 23 10:21:50 PST 2014


as free allow to pass a NULL pointer

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 lib/kfifo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/kfifo.c b/lib/kfifo.c
index 307dae1..601202d 100644
--- a/lib/kfifo.c
+++ b/lib/kfifo.c
@@ -70,6 +70,8 @@ struct kfifo *kfifo_alloc(unsigned int size)
  */
 void kfifo_free(struct kfifo *fifo)
 {
+	if (!fifo)
+		return;
 	free(fifo->buffer);
 	free(fifo);
 }
-- 
2.1.3




More information about the barebox mailing list