mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-29 23:32:14 +02:00
src: be more careful when freeing data
This commit is contained in:
1
src/at.c
1
src/at.c
@@ -206,6 +206,7 @@ int at_init(struct EG25Manager *manager)
|
|||||||
void at_destroy(struct EG25Manager *manager)
|
void at_destroy(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
g_source_remove(manager->at_source);
|
g_source_remove(manager->at_source);
|
||||||
|
if (manager->at_fd > 0)
|
||||||
close(manager->at_fd);
|
close(manager->at_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/gpio.c
10
src/gpio.c
@@ -189,9 +189,17 @@ void gpio_destroy(struct EG25Manager *manager)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < GPIO_OUT_COUNT; i++)
|
for (i = 0; i < GPIO_OUT_COUNT; i++) {
|
||||||
|
if (manager->gpio_out[i])
|
||||||
gpiod_line_release(manager->gpio_out[i]);
|
gpiod_line_release(manager->gpio_out[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < GPIO_IN_COUNT; i++) {
|
||||||
|
if (manager->gpio_in[i])
|
||||||
|
gpiod_line_release(manager->gpio_in[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (manager->gpiochip[0])
|
||||||
gpiod_chip_close(manager->gpiochip[0]);
|
gpiod_chip_close(manager->gpiochip[0]);
|
||||||
if (manager->gpiochip[1])
|
if (manager->gpiochip[1])
|
||||||
gpiod_chip_close(manager->gpiochip[1]);
|
gpiod_chip_close(manager->gpiochip[1]);
|
||||||
|
@@ -47,6 +47,9 @@ static void add_modem(struct EG25Manager *manager, GDBusObject *object)
|
|||||||
modem_configure(manager);
|
modem_configure(manager);
|
||||||
|
|
||||||
path = mm_modem_get_device(manager->mm_modem);
|
path = mm_modem_get_device(manager->mm_modem);
|
||||||
|
|
||||||
|
if (manager->modem_usb_id)
|
||||||
|
g_free(manager->modem_usb_id);
|
||||||
manager->modem_usb_id = g_strdup(strrchr(path, '/') + 1);
|
manager->modem_usb_id = g_strdup(strrchr(path, '/') + 1);
|
||||||
|
|
||||||
gdbus_modem = MM_GDBUS_MODEM(manager->mm_modem);
|
gdbus_modem = MM_GDBUS_MODEM(manager->mm_modem);
|
||||||
@@ -189,5 +192,12 @@ void mm_iface_init(struct EG25Manager *manager)
|
|||||||
|
|
||||||
void mm_iface_destroy(struct EG25Manager *manager)
|
void mm_iface_destroy(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
|
if (manager->mm_manager) {
|
||||||
g_clear_object(&manager->mm_manager);
|
g_clear_object(&manager->mm_manager);
|
||||||
|
manager->mm_manager = NULL;
|
||||||
|
}
|
||||||
|
if (manager->mm_watch != 0) {
|
||||||
|
g_bus_unwatch_name(manager->mm_watch);
|
||||||
|
manager->mm_watch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -114,11 +114,12 @@ static void name_owner_cb(GObject *object,
|
|||||||
g_assert(proxy == manager->suspend_proxy);
|
g_assert(proxy == manager->suspend_proxy);
|
||||||
|
|
||||||
owner = g_dbus_proxy_get_name_owner(proxy);
|
owner = g_dbus_proxy_get_name_owner(proxy);
|
||||||
if (owner)
|
if (owner) {
|
||||||
take_inhibitor(manager);
|
take_inhibitor(manager);
|
||||||
else
|
|
||||||
drop_inhibitor(manager);
|
|
||||||
g_free(owner);
|
g_free(owner);
|
||||||
|
} else {
|
||||||
|
drop_inhibitor(manager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_proxy_acquired(GObject *object,
|
static void on_proxy_acquired(GObject *object,
|
||||||
@@ -139,9 +140,10 @@ static void on_proxy_acquired(GObject *object,
|
|||||||
g_signal_connect(manager->suspend_proxy, "g-signal", G_CALLBACK(signal_cb), manager);
|
g_signal_connect(manager->suspend_proxy, "g-signal", G_CALLBACK(signal_cb), manager);
|
||||||
|
|
||||||
owner = g_dbus_proxy_get_name_owner(manager->suspend_proxy);
|
owner = g_dbus_proxy_get_name_owner(manager->suspend_proxy);
|
||||||
if (owner)
|
if (owner) {
|
||||||
take_inhibitor(manager);
|
take_inhibitor(manager);
|
||||||
g_free(owner);
|
g_free(owner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void suspend_init(struct EG25Manager *manager)
|
void suspend_init(struct EG25Manager *manager)
|
||||||
@@ -156,7 +158,10 @@ void suspend_init(struct EG25Manager *manager)
|
|||||||
void suspend_destroy(struct EG25Manager *manager)
|
void suspend_destroy(struct EG25Manager *manager)
|
||||||
{
|
{
|
||||||
drop_inhibitor(manager);
|
drop_inhibitor(manager);
|
||||||
|
if (manager->suspend_proxy) {
|
||||||
g_object_unref(manager->suspend_proxy);
|
g_object_unref(manager->suspend_proxy);
|
||||||
|
manager->suspend_proxy = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void suspend_inhibit(struct EG25Manager *manager, gboolean inhibit)
|
void suspend_inhibit(struct EG25Manager *manager, gboolean inhibit)
|
||||||
|
Reference in New Issue
Block a user