From: Daniel Wagner <wagi@monom.org>
To: connman@lists.linux.dev
Cc: Daniel Wagner <wagi@monom.org>
Subject: [PATCH] iwd: Do not try to handle out of memory fails
Date: Wed, 23 Jun 2021 09:22:54 +0200 [thread overview]
Message-ID: <20210623072254.30338-1-wagi@monom.org> (raw)
There is little point in trying to handle out of memory
situation. Most GLib function do fail with calling abort() when memory
allocation fails, e.g. g_strdup(). So fail hard when allocation the
iwd data structures.
---
plugins/iwd.c | 44 ++++++--------------------------------------
1 file changed, 6 insertions(+), 38 deletions(-)
diff --git a/plugins/iwd.c b/plugins/iwd.c
index 4ba107f3e113..14a442a7b67c 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -1372,13 +1372,7 @@ static void create_adapter(GDBusProxy *proxy)
struct iwd_adapter *iwda;
GSList *modes, *list;
- iwda = g_try_new0(struct iwd_adapter, 1);
-
- if (!iwda) {
- connman_error("Out of memory creating IWD adapter");
- return;
- }
-
+ iwda = g_new0(struct iwd_adapter, 1);
iwda->path = g_strdup(path);
g_hash_table_replace(adapters, iwda->path, iwda);
@@ -1423,13 +1417,7 @@ static void create_device(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_device *iwdd;
- iwdd = g_try_new0(struct iwd_device, 1);
-
- if (!iwdd) {
- connman_error("Out of memory creating IWD device");
- return;
- }
-
+ iwdd = g_new0(struct iwd_device, 1);
iwdd->path = g_strdup(path);
g_hash_table_replace(devices, iwdd->path, iwdd);
@@ -1596,13 +1584,7 @@ static void create_network(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_network *iwdn;
- iwdn = g_try_new0(struct iwd_network, 1);
-
- if (!iwdn) {
- connman_error("Out of memory creating IWD network");
- return;
- }
-
+ iwdn = g_new0(struct iwd_network, 1);
iwdn->path = g_strdup(path);
g_hash_table_replace(networks, iwdn->path, iwdn);
@@ -1682,12 +1664,7 @@ static void create_know_network(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_known_network *iwdkn;
- iwdkn = g_try_new0(struct iwd_known_network, 1);
- if (!iwdkn) {
- connman_error("Out of memory creating IWD known network");
- return;
- }
-
+ iwdkn = g_new0(struct iwd_known_network, 1);
iwdkn->path = g_strdup(path);
g_hash_table_replace(known_networks, iwdkn->path, iwdkn);
@@ -1721,12 +1698,7 @@ static void create_station(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_station *iwds;
- iwds = g_try_new0(struct iwd_station, 1);
- if (!iwds) {
- connman_error("Out of memory creating IWD station");
- return;
- }
-
+ iwds = g_new0(struct iwd_station, 1);
iwds->path = g_strdup(path);
g_hash_table_replace(stations, iwds->path, iwds);
@@ -1754,11 +1726,7 @@ static void create_ap(GDBusProxy *proxy)
const char *path = g_dbus_proxy_get_path(proxy);
struct iwd_ap *iwdap;
- iwdap = g_try_new0(struct iwd_ap, 1);
- if (!iwdap) {
- connman_error("Out of memory creating IWD access point");
- return;
- }
+ iwdap = g_new0(struct iwd_ap, 1);
iwdap->index = -1;
iwdap->path = g_strdup(path);
--
2.32.0
next reply other threads:[~2021-06-23 7:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 7:22 Daniel Wagner [this message]
2021-06-23 7:39 ` [PATCH] iwd: Do not try to handle out of memory fails Daniel Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210623072254.30338-1-wagi@monom.org \
--to=wagi@monom.org \
--cc=connman@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).