nordic-hid: Fix a few small memory leaks

This commit is contained in:
Richard Hughes 2021-12-14 12:56:19 +00:00
parent 53ed50e1c9
commit 4bf2469b88
2 changed files with 18 additions and 16 deletions

View File

@ -103,7 +103,7 @@ fu_nordic_hid_archive_parse(FuFirmware *firmware,
guint image_addr = 0; guint image_addr = 0;
JsonObject *obj = json_array_get_object_element(json_files, i); JsonObject *obj = json_array_get_object_element(json_files, i);
GBytes *blob = NULL; GBytes *blob = NULL;
FuFirmware *image = NULL; g_autoptr(FuFirmware) image = NULL;
g_autofree gchar *image_id = NULL; g_autofree gchar *image_id = NULL;
g_auto(GStrv) board_split = NULL; g_auto(GStrv) board_split = NULL;

View File

@ -114,6 +114,7 @@ fu_nordic_hid_cfg_channel_module_free(FuNordicCfgChannelModule *mod)
if (mod->options != NULL) if (mod->options != NULL)
g_ptr_array_unref(mod->options); g_ptr_array_unref(mod->options);
g_free(mod->name); g_free(mod->name);
g_free(mod);
} }
static gboolean static gboolean
@ -821,7 +822,8 @@ static gboolean
fu_nordic_hid_cfg_channel_setup(FuDevice *device, GError **error) fu_nordic_hid_cfg_channel_setup(FuDevice *device, GError **error)
{ {
FuNordicDeviceCfgChannel *self = FU_NORDIC_HID_CFG_CHANNEL(device); FuNordicDeviceCfgChannel *self = FU_NORDIC_HID_CFG_CHANNEL(device);
g_autofree gchar *target_id = NULL; g_autofree gchar *devid0 = NULL;
g_autofree gchar *devid1 = NULL;
if (!fu_nordic_hid_cfg_channel_index_peers(self, error)) if (!fu_nordic_hid_cfg_channel_index_peers(self, error))
return FALSE; return FALSE;
@ -839,19 +841,19 @@ fu_nordic_hid_cfg_channel_setup(FuDevice *device, GError **error)
/* additional GUID based on VID/PID and target area to flash /* additional GUID based on VID/PID and target area to flash
* needed to distinguish images aimed to different banks*/ * needed to distinguish images aimed to different banks*/
target_id = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&BOARD_%s&BL_%s", devid0 = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&BOARD_%s&BL_%s",
fu_udev_device_get_vendor(FU_UDEV_DEVICE(device)), fu_udev_device_get_vendor(FU_UDEV_DEVICE(device)),
fu_udev_device_get_model(FU_UDEV_DEVICE(device)), fu_udev_device_get_model(FU_UDEV_DEVICE(device)),
self->board_name, self->board_name,
self->bl_name); self->bl_name);
fu_device_add_guid(device, target_id); fu_device_add_guid(device, devid0);
target_id = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&BOARD_%s&BL_%s&BANK_%01X", devid1 = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&BOARD_%s&BL_%s&BANK_%01X",
fu_udev_device_get_vendor(FU_UDEV_DEVICE(device)), fu_udev_device_get_vendor(FU_UDEV_DEVICE(device)),
fu_udev_device_get_model(FU_UDEV_DEVICE(device)), fu_udev_device_get_model(FU_UDEV_DEVICE(device)),
self->board_name, self->board_name,
self->bl_name, self->bl_name,
self->flash_area_id); self->flash_area_id);
fu_device_add_guid(device, target_id); fu_device_add_guid(device, devid1);
return TRUE; return TRUE;
} }
@ -983,7 +985,7 @@ fu_nordic_hid_cfg_channel_write_firmware(FuDevice *device,
{ {
FuNordicDeviceCfgChannel *self = FU_NORDIC_HID_CFG_CHANNEL(device); FuNordicDeviceCfgChannel *self = FU_NORDIC_HID_CFG_CHANNEL(device);
guint32 checksum; guint32 checksum;
const gchar *csum_str = NULL; g_autofree gchar *csum_str = NULL;
g_autofree gchar *image_id = NULL; g_autofree gchar *image_id = NULL;
g_autoptr(GBytes) blob = NULL; g_autoptr(GBytes) blob = NULL;
g_autoptr(FuNordicCfgChannelDfuInfo) dfu_info = g_new0(FuNordicCfgChannelDfuInfo, 1); g_autoptr(FuNordicCfgChannelDfuInfo) dfu_info = g_new0(FuNordicCfgChannelDfuInfo, 1);