diff mbox series

[3/3] lte: Fix invalid cleanup

Message ID 20240227153314.1469536-3-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 6bf0a2541d43058ca789cd09046a131a430b7cb7
Headers show
Series [1/3] voicecall: Fix memory leak | expand

Commit Message

Denis Kenzior Feb. 27, 2024, 3:33 p.m. UTC
The intent was to have l_free apply to the settings variable, not the
const ap variable.  Also, while here, fix dereferencing ap if it is
NULL.

Fixes: 69adffb51633 ("lte: Add provisioning support")
---
 src/lte.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/lte.c b/src/lte.c
index 05491c3a1391..d6de408492c7 100644
--- a/src/lte.c
+++ b/src/lte.c
@@ -63,8 +63,8 @@  static bool provision_default_attach_info(struct ofono_lte *lte,
 						const char *mcc, const char *mnc,
 						const char *spn)
 {
-	struct provision_db_entry *settings;
-	_auto_(l_free) const struct provision_db_entry *ap = NULL;
+	_auto_(l_free) struct provision_db_entry *settings = NULL;
+	const struct provision_db_entry *ap = NULL;
 	size_t count;
 	size_t i;
 
@@ -83,7 +83,7 @@  static bool provision_default_attach_info(struct ofono_lte *lte,
 		}
 	}
 
-	if (!is_valid_apn(ap->apn))
+	if (!ap || !is_valid_apn(ap->apn))
 		return false;
 
 	if (ap->username && strlen(ap->username) >