2012/4/20 Anderson Lizardo <anderson.lizardo@xxxxxxxxxxxxx>: > Hi João, > > 2012/4/18 João Paulo Rechi Vita <jprvita@xxxxxxxxxxxxx>: >> int hog_device_register(struct btd_device *device, const char *path) >> { >> struct hog_device *hogdev; >> + struct gatt_primary *prim; >> >> hogdev = find_device_by_path(devices, path); >> if (hogdev) >> return -EALREADY; >> >> + prim = load_hog_primary(device); >> + if (!prim) >> + return -EINVAL; >> + >> hogdev = hog_device_new(device, path); >> - if (!hogdev) >> + if (!hogdev) { >> + g_free(prim); > > This g_free() call does not look correct. load_hog_primary() returns a > pointer to GSList data (more specifically from the primary service > list), which is freed in another part of BlueZ. > > So I think you can safely just return here. > Yes, you're right. Thanks for the catch. >> return -ENOMEM; >> + } >> + >> + hogdev->hog_primary = g_memdup(prim, sizeof(*prim)); >> >> hogdev->attioid = btd_device_add_attio_callback(device, >> attio_connected_cb, >> @@ -122,6 +154,7 @@ static void hog_device_free(struct hog_device *hogdev) >> { >> btd_device_unref(hogdev->device); >> g_free(hogdev->path); >> + g_free(hogdev->hog_primary); >> g_free(hogdev); >> } > > Regards, > -- > Anderson Lizardo > Instituto Nokia de Tecnologia - INdT > Manaus - Brazil -- João Paulo Rechi Vita Openbossa Labs - INdT -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html