mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-09 19:05:59 +00:00
android-boot: fix segfault
Store strings during the lifetime of the plugin and free them when destroyed.
This commit is contained in:
parent
5f554d1668
commit
c62e7a6bab
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
struct _FuAndroidBootDevice {
|
struct _FuAndroidBootDevice {
|
||||||
FuUdevDevice parent_instance;
|
FuUdevDevice parent_instance;
|
||||||
const gchar *label;
|
gchar *label;
|
||||||
const gchar *uuid;
|
gchar *uuid;
|
||||||
gchar *boot_slot;
|
gchar *boot_slot;
|
||||||
guint64 max_size;
|
guint64 max_size;
|
||||||
};
|
};
|
||||||
@ -42,7 +42,6 @@ fu_android_boot_device_probe(FuDevice *device, GError **error)
|
|||||||
{
|
{
|
||||||
FuAndroidBootDevice *self = FU_ANDROID_BOOT_DEVICE(device);
|
FuAndroidBootDevice *self = FU_ANDROID_BOOT_DEVICE(device);
|
||||||
GUdevDevice *udev_device = fu_udev_device_get_dev(FU_UDEV_DEVICE(device));
|
GUdevDevice *udev_device = fu_udev_device_get_dev(FU_UDEV_DEVICE(device));
|
||||||
g_autofree gchar *serial = NULL;
|
|
||||||
guint64 sectors = 0;
|
guint64 sectors = 0;
|
||||||
guint64 size = 0;
|
guint64 size = 0;
|
||||||
g_autoptr(GHashTable) cmdline = NULL;
|
g_autoptr(GHashTable) cmdline = NULL;
|
||||||
@ -65,7 +64,8 @@ fu_android_boot_device_probe(FuDevice *device, GError **error)
|
|||||||
|
|
||||||
/* extract label and check if it matches boot slot*/
|
/* extract label and check if it matches boot slot*/
|
||||||
if (g_udev_device_has_property(udev_device, "ID_PART_ENTRY_NAME")) {
|
if (g_udev_device_has_property(udev_device, "ID_PART_ENTRY_NAME")) {
|
||||||
self->label = g_udev_device_get_property(udev_device, "ID_PART_ENTRY_NAME");
|
self->label =
|
||||||
|
g_strdup(g_udev_device_get_property(udev_device, "ID_PART_ENTRY_NAME"));
|
||||||
|
|
||||||
/* Use label as device name */
|
/* Use label as device name */
|
||||||
fu_device_set_name(device, self->label);
|
fu_device_set_name(device, self->label);
|
||||||
@ -102,11 +102,10 @@ fu_android_boot_device_probe(FuDevice *device, GError **error)
|
|||||||
"device does not have a UUID");
|
"device does not have a UUID");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
self->uuid = g_udev_device_get_property(udev_device, "ID_PART_ENTRY_UUID");
|
self->uuid = g_strdup(g_udev_device_get_property(udev_device, "ID_PART_ENTRY_UUID"));
|
||||||
|
|
||||||
/* extract serial number and set it */
|
/* extract serial number and set it */
|
||||||
serial = g_hash_table_lookup(cmdline, "androidboot.serialno");
|
fu_device_set_serial(device, g_hash_table_lookup(cmdline, "androidboot.serialno"));
|
||||||
fu_device_set_serial(device, serial);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some devices don't have unique TYPE UUIDs, add the partition label to make them truly
|
* Some devices don't have unique TYPE UUIDs, add the partition label to make them truly
|
||||||
@ -334,6 +333,8 @@ fu_android_boot_device_finalize(GObject *obj)
|
|||||||
FuAndroidBootDevice *self = FU_ANDROID_BOOT_DEVICE(obj);
|
FuAndroidBootDevice *self = FU_ANDROID_BOOT_DEVICE(obj);
|
||||||
G_OBJECT_CLASS(fu_android_boot_device_parent_class)->finalize(obj);
|
G_OBJECT_CLASS(fu_android_boot_device_parent_class)->finalize(obj);
|
||||||
g_free(self->boot_slot);
|
g_free(self->boot_slot);
|
||||||
|
g_free(self->label);
|
||||||
|
g_free(self->uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user