diff mbox series

[04/11] qmi: gprs-context: Declare qmi_service objects using _auto_

Message ID 20240709225047.1427626-4-denkenz@gmail.com (mailing list archive)
State Superseded
Commit 766aa0ac819da8aafc24c4782ea76c422dfb1ab3
Headers show
Series [01/11] gobi: Limit number of premultiplexed contexts to 4 | expand

Commit Message

Denis Kenzior July 9, 2024, 10:50 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,