Clean up structures unused in case of all failures in hfa detect common
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 4a2be10..cff8267 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -597,7 +597,7 @@ static struct cgpu_info *hfa_old_device(struct cgpu_info *hashfast, struct hashf
static bool hfa_detect_common(struct cgpu_info *hashfast)
{
struct hashfast_info *info;
- bool ret;
+ bool ret = false;
int i;
info = calloc(sizeof(struct hashfast_info), 1);
@@ -606,16 +606,13 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
hashfast->device_data = info;
/* hashfast_reset should fill in details for info */
ret = hfa_reset(hashfast, info);
- if (!ret) {
- hfa_send_shutdown(hashfast);
- hfa_clear_readbuf(hashfast);
- free(info);
- hashfast->device_data = NULL;
- return false;
- }
+ if (!ret)
+ goto out;
- if (hashfast->usbinfo.nodev)
- return false;
+ if (hashfast->usbinfo.nodev) {
+ ret = false;
+ goto out;
+ }
// The per-die status array
info->die_status = calloc(info->asic_count, sizeof(struct hf_g1_die_data));
@@ -652,17 +649,18 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
if (info->hash_clock_rate != cinfo->hash_clock_rate) {
info->hash_clock_rate = cinfo->hash_clock_rate;
ret = hfa_reset(hashfast, hashfast->device_data);
- if (!ret) {
- hfa_send_shutdown(hashfast);
- hfa_clear_readbuf(hashfast);
- free(info);
- hashfast->device_data = NULL;
- return false;
- }
+ if (!ret)
+ goto out;
}
}
-
- return true;
+out:
+ if (!ret) {
+ hfa_send_shutdown(hashfast);
+ hfa_clear_readbuf(hashfast);
+ free(info);
+ hashfast->device_data = NULL;
+ }
+ return ret;
}
static bool hfa_initialise(struct cgpu_info *hashfast)