Skip to contentSkip to conversation

eventfd: check ida_simple_get() return value

PATCH New Bo Liu 1 participant 1 message Sep 7, 2022 VFS

lore
Share & tools
lore

Bo Liu

author
#0 lore raw

PATCH v2 1/1 eventfd: check ida_simple_get() return value

As ida_simple_get() can fail, we should check the return value.

---
 fs/eventfd.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/eventfd.c +4 -0
index c0ffee99ad23..208474d49ea4 100644
@@ -428,6 +428,10 @@ static int do_eventfd(unsigned int count, int flags)
 	ctx->count = count;
 	ctx->flags = flags;
 	ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL);
+	if (ctx->id < 0) {
+		fd = ctx->id;
+		goto err;
+	}
 
 	flags &= EFD_SHARED_FCNTL_FLAGS;
 	flags |= O_RDWR;
Signature · 1 line
2.27.0