osmo_io: Reject unknown/unsupported modes in osmo_iofd_setup()

The current code does not check the value range of the 'mode' parameter
and would later run into OSMO_ASSERT(), rather than rejecting such a
mode from the very beginning.

Change-Id: I10dd612487638f456d0ad59c2cca203f1e098da3
Related: OS#5751
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 1a8c01d..8507f46 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -445,7 +445,18 @@
 struct osmo_io_fd *osmo_iofd_setup(const void *ctx, int fd, const char *name, enum osmo_io_fd_mode mode,
 		  const struct osmo_io_ops *ioops, void *data)
 {
-	struct osmo_io_fd *iofd = talloc_zero(ctx, struct osmo_io_fd);
+	struct osmo_io_fd *iofd;
+
+	/* reject unsupported/unknown modes */
+	switch (mode) {
+	case OSMO_IO_FD_MODE_READ_WRITE:
+	case OSMO_IO_FD_MODE_RECVFROM_SENDTO:
+		break;
+	default:
+		return NULL;
+	}
+
+	iofd = talloc_zero(ctx, struct osmo_io_fd);
 	if (!iofd)
 		return NULL;