diff mbox series

[v2,07/11] qmi: gprs-context: Declare qmi_service objects using _auto_

Message ID 20240711164654.1688558-7-denkenz@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [v2,01/11] udevng: Remove gps from setup_gobi | expand

Commit Message

Denis Kenzior July 11, 2024, 4:46 p.m. UTC
This simplifies the error paths slightly.
---
 drivers/qmimodem/gprs-context.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index 3c18476142ea..7d13889bf603 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -554,7 +554,8 @@  static int qmi_gprs_context_probev(struct ofono_gprs_context *gc,
 					unsigned int vendor, va_list args)
 {
 	int mux_id = va_arg(args, int);
-	struct qmi_service *wds = va_arg(args, struct qmi_service *);
+	_auto_(qmi_service_free) struct qmi_service *wds =
+					va_arg(args, struct qmi_service *);
 	struct gprs_context_data *data;
 
 	DBG("");
@@ -562,14 +563,12 @@  static int qmi_gprs_context_probev(struct ofono_gprs_context *gc,
 	if (mux_id != -1) {
 		int r = qmi_gprs_context_bind_mux(gc, wds, mux_id);
 
-		if (r < 0) {
-			qmi_service_free(wds);
+		if (r < 0)
 			return r;
-		}
 	}
 
 	data = l_new(struct gprs_context_data, 1);
-	data->wds = wds;
+	data->wds = l_steal_ptr(wds);
 	data->mux_id = mux_id;
 
 	qmi_service_register(data->wds, QMI_WDS_PACKET_SERVICE_STATUS,