This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgMax has submitted this change and it was merged.
Change subject: Handle ctrl cmd allocation failures
......................................................................
Handle ctrl cmd allocation failures
Check that ctrl command was successfully allocated before using it.
Fixes: CID163884
Change-Id: Id19e1ce5fae6f936c9ed93f9a6317b57d28d7311
---
M src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c
1 file changed, 19 insertions(+), 18 deletions(-)
Approvals:
Neels Hofmeyr: Looks good to me, approved
Harald Welte: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c
index 2a15d2e..f01fd14 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c
@@ -190,21 +190,13 @@
struct ctrl_connection *ctrl, int critical,
int warning)
{
- int new_state = next_state(manager->state, critical, warning), rc;
+ int new_state = next_state(manager->state, critical, warning);
struct ctrl_cmd *rep;
- bool send = false;
+ char *oml_alert = NULL;
/* Nothing changed */
if (new_state < 0)
return;
-
- rep = ctrl_cmd_create(tall_mgr_ctx, CTRL_TYPE_SET);
- if (!rep) {
- LOGP(DTEMP, LOGL_ERROR, "OML alert creation failed.\n");
- } else {
- rep->id = talloc_asprintf(rep, "%d", rand());
- rep->variable = "oml-alert";
- }
LOGP(DTEMP, LOGL_NOTICE, "Moving from state %s to %s.\n",
get_value_string(state_names, manager->state),
@@ -219,22 +211,31 @@
break;
case STATE_WARNING:
execute_warning_act(manager);
- rep->value = "Temperature Warning";
- send = true;
+ oml_alert = "Temperature Warning";
break;
case STATE_CRITICAL:
execute_critical_act(manager);
- rep->value = "Temperature Critical";
- send = true;
+ oml_alert = "Temperature Critical";
break;
};
- if (send) {
- rc = ctrl_cmd_send(&ctrl->write_queue, rep);
- LOGP(DTEMP, LOGL_ERROR, "OML alert sent: %d\n", rc);
+ if (!oml_alert)
+ return;
+
+ rep = ctrl_cmd_create(tall_mgr_ctx, CTRL_TYPE_SET);
+ if (!rep) {
+ LOGP(DTEMP, LOGL_ERROR, "OML alert creation failed for %s.\n",
+ oml_alert);
+ return;
}
+
+ rep->id = talloc_asprintf(rep, "%d", rand());
+ rep->variable = "oml-alert";
+ rep->value = oml_alert;
+ LOGP(DTEMP, LOGL_ERROR, "OML alert sent: %d\n",
+ ctrl_cmd_send(&ctrl->write_queue, rep));
talloc_free(rep);
-}
+}
static void temp_ctrl_check(struct ctrl_connection *ctrl)
{
--
To view, visit https://gerrit.osmocom.org/1991
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id19e1ce5fae6f936c9ed93f9a6317b57d28d7311
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>