]> sigrok.org Git - libsigrok.git/commitdiff
sr: fx2lafw: Fix potential leaks in acquisition_start error paths
authorLars-Peter Clausen <redacted>
Tue, 3 Jul 2012 21:58:40 +0000 (23:58 +0200)
committerBert Vermeulen <redacted>
Tue, 3 Jul 2012 23:11:50 +0000 (01:11 +0200)
Call abort_acquisition if starting sampling fails in acquisition_start, this
will ensure that all already allocated resources are being freed again.

Signed-off-by: Lars-Peter Clausen <redacted>
hardware/fx2lafw/fx2lafw.c

index 11e41fffe410f31c14af570948498b5f129c860a..59ad5e73053fb111805b8e5af43535d842228254 100644 (file)
@@ -946,9 +946,9 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
                                2 | LIBUSB_ENDPOINT_IN, buf, size,
                                receive_transfer, ctx, timeout);
                if (libusb_submit_transfer(transfer) != 0) {
-                       /* TODO: Free them all. */
                        libusb_free_transfer(transfer);
                        g_free(buf);
+                       abort_acquisition(ctx);
                        return SR_ERR;
                }
                ctx->transfers[i] = transfer;
@@ -976,6 +976,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
 
        if ((ret = command_start_acquisition (ctx->usb->devhdl,
                ctx->cur_samplerate, ctx->sample_wide)) != SR_OK) {
+               abort_acquisition(ctx);
                return ret;
        }