[PATCH] osmo-bts[master]: Handle ctrl cmd allocation failures

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.org
Tue Mar 7 16:46:11 UTC 2017


Review at  https://gerrit.osmocom.org/1991

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, 10 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/91/1991/1

diff --git a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c
index 2a15d2e..508fc11 100644
--- a/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c
+++ b/src/osmo-bts-sysmo/misc/sysmobts_mgr_temp.c
@@ -192,7 +192,6 @@
 {
 	int new_state = next_state(manager->state, critical, warning), rc;
 	struct ctrl_cmd *rep;
-	bool send = false;
 
 	/* Nothing changed */
 	if (new_state < 0)
@@ -219,21 +218,23 @@
 		break;
 	case STATE_WARNING:
 		execute_warning_act(manager);
-		rep->value = "Temperature Warning";
-		send = true;
+		if (rep)
+			rep->value = "Temperature Warning";
 		break;
 	case STATE_CRITICAL:
 		execute_critical_act(manager);
-		rep->value = "Temperature Critical";
-		send = true;
+		if (rep)
+			rep->value = "Temperature Critical";
 		break;
 	};
 
-	if (send) {
-		rc = ctrl_cmd_send(&ctrl->write_queue, rep);
-		LOGP(DTEMP, LOGL_ERROR, "OML alert sent: %d\n", rc);
+	if (rep) {
+		if (rep->value) {
+			rc = ctrl_cmd_send(&ctrl->write_queue, rep);
+			LOGP(DTEMP, LOGL_ERROR, "OML alert sent: %d\n", rc);
+		}
+		talloc_free(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: newchange
Gerrit-Change-Id: Id19e1ce5fae6f936c9ed93f9a6317b57d28d7311
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list