From 475ec27e526686ae2eed72df688f174cc662371c Mon Sep 17 00:00:00 2001 From: Krzysztof Czurylo Date: Tue, 10 Apr 2018 17:27:55 +0200 Subject: [PATCH] rpmem: early return from rpmem_read if len is 0 Ref: pmem/issues#850 --- src/librpmem/rpmem_fip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librpmem/rpmem_fip.c b/src/librpmem/rpmem_fip.c index 05af45c8077..dd0d836d96c 100644 --- a/src/librpmem/rpmem_fip.c +++ b/src/librpmem/rpmem_fip.c @@ -1268,7 +1268,6 @@ rpmem_fip_persist(struct rpmem_fip *fip, size_t offset, size_t len, return 0; } - int ret = 0; while (len > 0) { size_t tmp_len = len < fip->fi->ep_attr->max_msg_size ? @@ -1306,6 +1305,10 @@ rpmem_fip_read(struct rpmem_fip *fip, void *buff, size_t len, if (unlikely(lane >= fip->nlanes)) return EINVAL; /* it will be passed to errno */ + if (unlikely(len == 0)) { + return 0; + } + size_t rd_buff_len = len < fip->fi->ep_attr->max_msg_size ? len : fip->fi->ep_attr->max_msg_size;