Skip to content

Instantly share code, notes, and snippets.

@Demon000
Last active December 11, 2020 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Demon000/2a3c1c6545346416b2e9efc7c39408cd to your computer and use it in GitHub Desktop.
Save Demon000/2a3c1c6545346416b2e9efc7c39408cd to your computer and use it in GitHub Desktop.
From 275b0d3210039ec3c5b5e3a08f771a80643bc893 Mon Sep 17 00:00:00 2001
From: Cosmin Tanislav <demonsingur@gmail.com>
Date: Thu, 10 Dec 2020 16:48:54 -0500
Subject: [PATCH] bugfix: runtime: transport: handle more error cases in module
init
---
runtime/transport/relay_v2.c | 1 +
runtime/transport/transport.c | 20 +++++++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/runtime/transport/relay_v2.c b/runtime/transport/relay_v2.c
index 2ba5eea..27729f4 100644
--- a/runtime/transport/relay_v2.c
+++ b/runtime/transport/relay_v2.c
@@ -277,6 +277,7 @@ static int _stp_transport_data_fs_init(void)
#endif /* (RELAYFS_CHANNEL_VERSION < 7) */
if (!_stp_relay_data.rchan) {
rc = -ENOENT;
+ errk("%s: relay_open() failed: %d\n", THIS_MODULE->name, rc);
goto err;
}
/* Increment _stp_allocated_memory and _stp_allocated_net_memory to account for buffers
diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
index 1be3e94..f005e14 100644
--- a/runtime/transport/transport.c
+++ b/runtime/transport/transport.c
@@ -552,6 +552,8 @@ static void _stp_transport_close(void)
*/
static int _stp_transport_init(void)
{
+ int ret;
+
dbug_trans(1, "transport_init\n");
#ifdef STAPCONF_TASK_UID
_stp_uid = current->uid;
@@ -603,20 +605,28 @@ static int _stp_transport_init(void)
dbug_trans(1, "Using %d subbufs of size %d\n", _stp_nsubbufs, _stp_subbuf_size);
}
- if (_stp_transport_fs_init(THIS_MODULE->name) != 0)
+ ret = _stp_transport_fs_init(THIS_MODULE->name);
+ if (ret)
goto err0;
/* create control channel */
- if (_stp_register_ctl_channel() < 0)
+ ret = _stp_register_ctl_channel();
+ if (ret < 0)
goto err1;
/* create print buffers */
- if (_stp_print_init() < 0)
+ ret = _stp_print_init();
+ if (ret < 0) {
+ errk("%s: can't create print buffers!", THIS_MODULE->name);
goto err2;
+ }
/* set _stp_module_self dynamic info */
- if (_stp_module_update_self() < 0)
+ ret = _stp_module_update_self();
+ if (ret < 0) {
+ errk("%s: can't update dynamic info!", THIS_MODULE->name);
goto err3;
+ }
/* start transport */
_stp_transport_data_fs_start();
@@ -639,7 +649,7 @@ err2:
err1:
_stp_transport_fs_close();
err0:
- return -1;
+ return ret;
}
static inline void _stp_lock_inode(struct inode *inode)
--
1.8.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment