diff mbox

[16/18] fs_context: de-obfuscate control flow in fscontext_read()

Message ID 20180708210154.10423-17-ebiggers3@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Biggers July 8, 2018, 9:01 p.m. UTC
From: Eric Biggers <ebiggers@google.com>

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/fsopen.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
diff mbox

Patch

diff --git a/fs/fsopen.c b/fs/fsopen.c
index 1fbd8b0ca194b..dd38f6b65aace 100644
--- a/fs/fsopen.c
+++ b/fs/fsopen.c
@@ -161,20 +161,18 @@  static ssize_t fscontext_read(struct file *file,
 	if (ret < 0)
 		return ret;
 
-	ret = -ENODATA;
-	if (log->head != log->tail) {
-		index = log->tail & (logsize - 1);
-		p = log->buffer[index];
-		need_free = log->need_free & (1 << index);
-		log->buffer[index] = NULL;
-		log->need_free &= ~(1 << index);
-		log->tail++;
-		ret = 0;
+	if (log->head == log->tail) {
+		mutex_unlock(&fc->uapi_mutex);
+		return -ENODATA;
 	}
 
+	index = log->tail & (logsize - 1);
+	p = log->buffer[index];
+	need_free = log->need_free & (1 << index);
+	log->buffer[index] = NULL;
+	log->need_free &= ~(1 << index);
+	log->tail++;
 	mutex_unlock(&fc->uapi_mutex);
-	if (ret < 0)
-		return ret;
 
 	ret = -EMSGSIZE;
 	n = strlen(p);