From patchwork Tue Feb 27 15:33:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13574030 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61DED13A89E for ; Tue, 27 Feb 2024 15:33:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709047999; cv=none; b=fBegdHOu08JJt9zgwGKEzLQMZcY1p0LxoeOS0tnI3VwymljyDgYzczNoHj/AVhqkrexkFQW+q865zDJ9ibDNuiQka6k0iXbtnLWhwyj7tfqFOqDU8W9tBR9a8luoGI/C6YXH37t3D2V5U46tlIyuWw7iqsP6mYWFqtwC1dDDNAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709047999; c=relaxed/simple; bh=FqH937Zd2Psp4Ink2Vg12UW8H1hSlLSy03467Vq1FwA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=T3F8UGHrGGoFJXoYgfeYNlRVJI2FVbmjowliK5zjivv2a3rrTLElioZdN55ScRJwigLE4t0WNxTih9d8++sBBhiVuSKpSNugibLss/rmfvDvBHVQUs5IWXBhrv3BPOilCf5THUCn5hpX7xJZu3bva+ZEywzWRSMJCTdsB2a5sFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SwwqCStA; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SwwqCStA" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e48153c13aso2014614a34.3 for ; Tue, 27 Feb 2024 07:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709047997; x=1709652797; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kRPZ/wEqfgaM52yETEmxo8qlwUembmUhN8sHz5fGjXE=; b=SwwqCStAs5zCSPsB6YFxruYfy8clLRrnr00rzspAGkZXbkZupozBB5PbydPyDpZklN VwDVc0jM7DKbna/SSiRu69TYsuRBdFjIvttHGe0p4QJTHGCEhwaCB/C+UGmnwFaUCbXN llPwbQ+oUWdphAxqUMa91pFTJ21ii0Ne54JkTRshFowjDdZ0c53EP7bALagoxe086LRP I0z5f8qdM9zFMTioIfdKC3mg/CJyhk981VG5k5J1gtNWIC5BsRc9ALPaW2jWCEgTWNJ/ 8DM3YbRo7tGJxg67iQDgjks2p7DMrCgeSVl3osCTvYIy2Uf8aN/O71Gd8+IjEHKxM+NN DXWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709047997; x=1709652797; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kRPZ/wEqfgaM52yETEmxo8qlwUembmUhN8sHz5fGjXE=; b=Zo7D6bk5tzjWSZTI2exIODl7VYtEgt/KvYDdsWRtC3ES16YmsaJ/SYggzfbOU58PpP S7LgesW17gCoaaCdJwmyRI/qDima0O1DIzOpd062rJIKJKTl0TLWTO1Zrz+KPbrG+X/m pfVzjru2hDAN3mCdyuzbDWT6fM7mgAI6wtHLY/0ww1WF7+/yDHiPfYpvd5Mvrmdi88AS fLa3yG9lt+oS5g1ht8GnW/cheYf9RMoI4xiwqtEmxEr41wxxz+48z7gtZJjJueNFFptS W8I04WRYLJ/xpu4Toah3VAd6Rj3LskFKhWM8qyBDZ4CDgG9HU0vMZP1IwIjhEQO3GMtD Wilg== X-Gm-Message-State: AOJu0Yx3781jucPnw/DEAWS6jLN7MIVK+JkqhWl6FbtSVKjjYqQupJzf k9HZYORStcFEjo/bmixp1IUjie7JaxRkR0F9nrJPoP6p4rkSxmtLLS6kJ8qz X-Google-Smtp-Source: AGHT+IGEHUKKnT2e4YKBgGnjSFtFMs5uYdQD3InC0Apq8YM/DNkoJAKHkBOGPTUv2qfKKNn8ugiBcA== X-Received: by 2002:a9d:6249:0:b0:6e4:a1a1:8d78 with SMTP id i9-20020a9d6249000000b006e4a1a18d78mr4588710otk.2.1709047997349; Tue, 27 Feb 2024 07:33:17 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id l13-20020a9d6a8d000000b006e477a4207fsm1538589otq.54.2024.02.27.07.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 07:33:16 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 1/3] voicecall: Fix memory leak Date: Tue, 27 Feb 2024 09:33:02 -0600 Message-ID: <20240227153314.1469536-1-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 'number' is obtained using g_key_file_get_string (which returns a newly allocated string), but is never freed. --- src/voicecall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index d10fe15a423d..f979c46fe132 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -3462,7 +3462,7 @@ static void emulator_dial_callback(const struct ofono_error *error, void *data) struct ofono_voicecall *vc = data; gboolean need_to_emit; struct voicecall *v; - const char *number; + char *number; GError *err = NULL; number = g_key_file_get_string(vc->settings, SETTINGS_GROUP, @@ -3484,6 +3484,8 @@ static void emulator_dial_callback(const struct ofono_error *error, void *data) if (need_to_emit) voicecalls_emit_call_added(vc, v); + + g_free(number); } static void emulator_dial(struct ofono_emulator *em, struct ofono_voicecall *vc, @@ -3585,7 +3587,7 @@ static void emulator_bldn_cb(struct ofono_emulator *em, struct ofono_emulator_request *req, void *userdata) { struct ofono_voicecall *vc = userdata; - const char *number; + char *number = NULL; struct ofono_error result; GError *error = NULL; @@ -3608,6 +3610,8 @@ fail: result.type = OFONO_ERROR_TYPE_FAILURE; ofono_emulator_send_final(em, &result); }; + + g_free(number); } static void emulator_hfp_watch(struct ofono_atom *atom, From patchwork Tue Feb 27 15:33:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13574031 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10E08145322 for ; Tue, 27 Feb 2024 15:33:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709048000; cv=none; b=hFjWNFNYobHaeadWERK5mJ844vqqVE/qxSfPNKI19bOqadtpVw4VA7Zm8yOMjubV4wKhuOzMMV9cSWke2eawjjUJxOqondcMiHOtfZuswf0MHbf8vZ8nP+MJIokwNc/kT9tNSmhqGrJdkq5hfAyx2WhHYRNRj8NrZwroI6b6TCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709048000; c=relaxed/simple; bh=DRA7WCeACunwey7CTSjf/QqLa3Uiu85qeTkzynlBnN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SNwO10xLi/mdgK76okSgy5mbbylei4FjcgrtBngtNuJeYdGYQJI3PliLLa5tiCJvqURe5am86xbs28EOivtNGfViHcO7PtBdvxRAUgh1Ihs3A0kXjKKyxPuGZ5Tw50W0m+Aytbt4y2+tZuBqqOG5NT87fpHo+KVo55ScITHsY6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y4JzsR36; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y4JzsR36" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6e45ef83c54so2753168a34.2 for ; Tue, 27 Feb 2024 07:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709047998; x=1709652798; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BNrf8JKJhvobJUbzR1kSVecV5eVWf0NyYhIAWjYX6a4=; b=Y4JzsR369jA09Zws6kA+s3y+FdjMZpNqfUAEDAPEd/YtuZ7zloX2mVM9AuGYLiUAY9 062vQGYTU6EPf1CAvvfvZuqMUwHXrnygF6p6hne6kND43g6vsc+ihwG2grGe8QJt9bjN bOhG+tLP9fQNcJhoLgqWKfBCsNlm7vBkDUwHKRRyUD9cJnFGechYE0OCIPoOIXLOqykr F+dH4ttdeHcb9m68oyGKRpYPKBL/e4PbaBSptRv396JCSbbol4hJJTi/lyAvErDeRKVf ElqrxA3n8KGGaUKGCAOLViKr6hJl6YV/HupbGM/92msu9P9ApqUDLCWgz80Z4e9YOb5l Xggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709047998; x=1709652798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BNrf8JKJhvobJUbzR1kSVecV5eVWf0NyYhIAWjYX6a4=; b=BOSt56Y8qiXELv/Fyu/bvoUiI2fC3vZCVpdyn5juO6Pl7uEVTskfZpZ4WhF2tkFUdg /tznHSutIMwGc6F3iJd1uNie8YEbs8bM7z+FDCVPf0cYgsE38mkNeC6V7RirOiCVol2k smrhGlJrd/2yVxahU3ic/fsXQX7O9lxnY5C5FYgAjfVmWraWJ0kHaHLsc3kTPlzmHxjq fyJUTYEDN5X62tDKO5irTkiVAWO6opYPmKLZuJ15MKKIFzIBZcWoH3ykTEOFC6bo8npD UDRv5/coX+o5PgjI/9B3K8+y6Cx4G+DQXpT66m6PMc3Vy8W4zVtPgWB6B2YdtwjKfSnV 8R7w== X-Gm-Message-State: AOJu0Yyi2Cse3WLMpdv/ST8wmwqUQl6tuEgAmchVNzTHSjpSC63dgFd9 8bgkxHc1qUzkCxwDDWEAbla/YMeWREU6Qr1fMxksfUMcusiZlzvB/AVShlsr X-Google-Smtp-Source: AGHT+IGVJVL/I/MYXIz+SvdP/9JOUiswxdfWUojmrsT2xzPEaIcTF8YKY5QdYO5RX9+QUrFtakhO5A== X-Received: by 2002:a9d:3e51:0:b0:6e4:aa2b:5475 with SMTP id h17-20020a9d3e51000000b006e4aa2b5475mr2675900otg.0.1709047998055; Tue, 27 Feb 2024 07:33:18 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id l13-20020a9d6a8d000000b006e477a4207fsm1538589otq.54.2024.02.27.07.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 07:33:17 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 2/3] voicecall: Fix use after free Date: Tue, 27 Feb 2024 09:33:03 -0600 Message-ID: <20240227153314.1469536-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227153314.1469536-1-denkenz@gmail.com> References: <20240227153314.1469536-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If voicecall_dbus_register is not successful, it will invoke voicecall_destroy, which frees the voicecall and associated data. Make sure to return early if this happens. While here, convert g_memdup2 and g_try_new0 use to ell. --- src/voicecall.c | 70 +++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 49 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index f979c46fe132..4ce161b54600 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -671,11 +671,7 @@ static const GDBusSignalTable voicecall_signals[] = { static struct voicecall *voicecall_create(struct ofono_voicecall *vc, struct ofono_call *call) { - struct voicecall *v; - - v = g_try_new0(struct voicecall, 1); - if (v == NULL) - return NULL; + struct voicecall *v = l_new(struct voicecall, 1); v->call = call; v->vc = vc; @@ -687,10 +683,10 @@ static void voicecall_destroy(gpointer userdata) { struct voicecall *voicecall = (struct voicecall *)userdata; - g_free(voicecall->call); + l_free(voicecall->call); l_free(voicecall->message); - g_free(voicecall); + l_free(voicecall); } static const char *voicecall_build_path(struct ofono_voicecall *vc, @@ -1051,13 +1047,13 @@ static void voicecall_set_call_name(struct voicecall *v, DBUS_TYPE_STRING, &name_str); } -static gboolean voicecall_dbus_register(struct voicecall *v) +static bool voicecall_dbus_register(struct voicecall *v) { DBusConnection *conn = ofono_dbus_get_connection(); const char *path; if (v == NULL) - return FALSE; + return false; path = voicecall_build_path(v->vc, v->call); @@ -1068,10 +1064,10 @@ static gboolean voicecall_dbus_register(struct voicecall *v) ofono_error("Could not register VoiceCall %s", path); voicecall_destroy(v); - return FALSE; + return false; } - return TRUE; + return true; } static gboolean voicecall_dbus_unregister(struct ofono_voicecall *vc, @@ -1357,20 +1353,16 @@ static struct voicecall *synthesize_outgoing_call(struct ofono_voicecall *vc, struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); struct ofono_call *call; struct voicecall *v; + unsigned int id; - call = g_try_new0(struct ofono_call, 1); - if (call == NULL) - return NULL; - - call->id = __ofono_modem_callid_next(modem); - - if (call->id == 0) { + id = __ofono_modem_callid_next(modem); + if (!id) { ofono_error("Failed to alloc callid, too many calls"); - g_free(call); return NULL; } - __ofono_modem_callid_hold(modem, call->id); + call = l_new(struct ofono_call, 1); + call->id = id; if (number) string_to_phone_number(number, &call->phone_number); @@ -1380,16 +1372,15 @@ static struct voicecall *synthesize_outgoing_call(struct ofono_voicecall *vc, call->clip_validity = CLIP_VALIDITY_VALID; v = voicecall_create(vc, call); - if (v == NULL) { - g_free(call); - return NULL; - } - v->detect_time = time(NULL); DBG("Registering new call: %d", call->id); - voicecall_dbus_register(v); + if (!voicecall_dbus_register(v)) { + ofono_error("Unable to register synthetic voice call"); + return NULL; + } + __ofono_modem_callid_hold(modem, call->id); vc->call_list = g_slist_insert_sorted(vc->call_list, v, call_compare); return v; @@ -2384,7 +2375,7 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc, { struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom); GSList *l; - struct voicecall *v = NULL; + struct voicecall *v; struct ofono_call *newcall; DBG("Got a voicecall event, status: %s (%d), id: %u, number: %s" @@ -2410,19 +2401,8 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc, DBG("Did not find a call with id: %d", call->id); - __ofono_modem_callid_hold(modem, call->id); - - newcall = g_memdup2(call, sizeof(struct ofono_call)); - if (newcall == NULL) { - ofono_error("Unable to allocate call"); - goto error; - } - + newcall = l_memdup(call, sizeof(struct ofono_call)); v = voicecall_create(vc, newcall); - if (v == NULL) { - ofono_error("Unable to allocate voicecall_data"); - goto error; - } if (vc->flags & VOICECALL_FLAG_STK_MODEM_CALLSETUP) { struct dial_request *req = vc->dial_req; @@ -2460,21 +2440,13 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc, if (!voicecall_dbus_register(v)) { ofono_error("Unable to register voice call"); - goto error; + return; } + __ofono_modem_callid_hold(modem, call->id); vc->call_list = g_slist_insert_sorted(vc->call_list, v, call_compare); voicecalls_emit_call_added(vc, v); - - return; - -error: - if (newcall) - g_free(newcall); - - if (v) - g_free(v); } void ofono_voicecall_mpty_hint(struct ofono_voicecall *vc, unsigned int ids) From patchwork Tue Feb 27 15:33:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13574032 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED18A14533E for ; Tue, 27 Feb 2024 15:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709048001; cv=none; b=d7VGXRkWmBnp4mJktpmAgrWBVjQEPA432BOLVpkLsD4fYVUu9Hr8HdG/zuqbmCPBzkpCdTGUR3IpJURAN71o5nX4YmgskYLQgaKUs3IbdrLVeNKyhBXmilFTnpU27UpWIiOX5XjXOHg7wcl/ngtkf7XGI+m39faEGi6UQYZsGzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709048001; c=relaxed/simple; bh=RBiMYgH+lp1LcWsCjvRTWvdz7aZpoRdYNEs33SR4+Qg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bKHljTWDaBoLNQthiyls5ZKrcLBjch+GEUMZ1HcLxgCXur29RRkkbTx++C8Y9BeZXH6pRKJJARHgk9xnz9WX0XTQzMIV/tvXOJANdOsOJVwPHWVo3lZI7EEBbPGRRq5I1VQ47N9ZRctDsb0dYXsS8XDENHVsLVnmmZ+b975PxLw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UtgFiaOF; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UtgFiaOF" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6ddf26eba3cso3477281a34.0 for ; Tue, 27 Feb 2024 07:33:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709047999; x=1709652799; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Wh6VR9xzPdF7uIlQXwiCpNNf5KAHqKCRSnmQJBhuIg=; b=UtgFiaOFRD3mJVxLhXccazE3Aa7eKteQOu9htDrZMw9/4kP/OWsEeu0dcMls/GamoA 1bwUkAhAaKpadvNwM/1m4Xr99TDYMb1Y7j+cIrtggDDwnAmhqXgs5U5OWfN2tBW/of7y rdsc1l6X7TiDsAeRRzCjLOis+PLh/Ah5HuSR+E5TGCbzGR7lktSo3S9Kt3EmpWxXCeVi hDC5vZTaCMNHV9vG9bBZQbBCuh8xP5gm0Gz5SsLg2yv+gtYBcTbva1FaNo4exMhUttj2 GMiK3stFazPysuRYWo4iwTEt0t6IbDPwaGiWQ8oaw9QVocYvEcDmjBEa+dP7D8JJABp9 8y1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709047999; x=1709652799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Wh6VR9xzPdF7uIlQXwiCpNNf5KAHqKCRSnmQJBhuIg=; b=CG3gQVFFg1ajOcP09vmArDp+hlZM8NhXeOB+ZM0hCv4IDCjL2MNtwz7tGtVrd70nAZ dcqDKm/wPCwL392/ICjC80TmazAjylsLfpuahmqsNzbxJ6/yAZ7lrIO3naoiaovQ3pwm lj+RalHsHLaRV2uHEbOUbok4uEHtQS2ByCAkpbxJw1KFH9aLXC2J8EP2MYjOb8Gt0Mtw YDR1USWxf3u7jG9+ER0AYPbNVzA1otcWb0prdNjzNMZWGM4Fo4giD94TC3sO7BIg/jEl yW64eiWpwOjNVbviCf+IKiOlbyTcx+25BiMNzcT0+TPLMW0NHFyW4MYKKZrkFAeaeooo WErQ== X-Gm-Message-State: AOJu0YzJgW1ch5Cpk/ZCpP2jKvtsuysb9zJHU+3L5z0iLDGx06300iqH +zz427Q8LcbV/qDW5HxXktCFOYjN98SyoHi9f7W8DsIz7pqnruJXniOVTqRf X-Google-Smtp-Source: AGHT+IGc1ypsI04AAMUVy3lWQ+GziF2q59vA1Ry5pnszaa2cwwq3hFLBq+gAh+TUaSqHpTJMabBHjA== X-Received: by 2002:a05:6830:22db:b0:6e4:7b7e:72ba with SMTP id q27-20020a05683022db00b006e47b7e72bamr10759560otc.38.1709047998763; Tue, 27 Feb 2024 07:33:18 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id l13-20020a9d6a8d000000b006e477a4207fsm1538589otq.54.2024.02.27.07.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 07:33:18 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 3/3] lte: Fix invalid cleanup Date: Tue, 27 Feb 2024 09:33:04 -0600 Message-ID: <20240227153314.1469536-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227153314.1469536-1-denkenz@gmail.com> References: <20240227153314.1469536-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --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) >