uart drivers: missing nfc_device_free() on some error handling branches

This commit is contained in:
Philippe Teuwen 2013-03-17 23:51:16 +01:00
parent 2e801a62d5
commit 5f70bdc699
3 changed files with 10 additions and 0 deletions

View file

@ -438,6 +438,7 @@ acr122s_scan(const nfc_context *context, nfc_connstring connstrings[], const siz
if (!pnd->driver_data) { if (!pnd->driver_data) {
perror("malloc"); perror("malloc");
uart_close(sp); uart_close(sp);
nfc_device_free(pnd);
return -1; return -1;
} }
DRIVER_DATA(pnd)->port = sp; DRIVER_DATA(pnd)->port = sp;
@ -446,6 +447,7 @@ acr122s_scan(const nfc_context *context, nfc_connstring connstrings[], const siz
#ifndef WIN32 #ifndef WIN32
if (pipe(DRIVER_DATA(pnd)->abort_fds) < 0) { if (pipe(DRIVER_DATA(pnd)->abort_fds) < 0) {
uart_close(DRIVER_DATA(pnd)->port); uart_close(DRIVER_DATA(pnd)->port);
nfc_device_free(pnd);
return 0; return 0;
} }
#else #else

View file

@ -129,6 +129,7 @@ arygon_scan(const nfc_context *context, nfc_connstring connstrings[], const size
if (!pnd->driver_data) { if (!pnd->driver_data) {
perror("malloc"); perror("malloc");
uart_close(sp); uart_close(sp);
nfc_device_free(pnd);
return 0; return 0;
} }
DRIVER_DATA(pnd)->port = sp; DRIVER_DATA(pnd)->port = sp;
@ -140,6 +141,7 @@ arygon_scan(const nfc_context *context, nfc_connstring connstrings[], const size
// pipe-based abort mecanism // pipe-based abort mecanism
if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) { if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) {
uart_close(DRIVER_DATA(pnd)->port); uart_close(DRIVER_DATA(pnd)->port);
nfc_device_free(pnd);
return 0; return 0;
} }
#else #else
@ -250,6 +252,7 @@ arygon_open(const nfc_context *context, const nfc_connstring connstring)
if (!pnd->driver_data) { if (!pnd->driver_data) {
perror("malloc"); perror("malloc");
uart_close(sp); uart_close(sp);
nfc_device_free(pnd);
return NULL; return NULL;
} }
DRIVER_DATA(pnd)->port = sp; DRIVER_DATA(pnd)->port = sp;
@ -268,6 +271,7 @@ arygon_open(const nfc_context *context, const nfc_connstring connstring)
// pipe-based abort mecanism // pipe-based abort mecanism
if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) { if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) {
uart_close(DRIVER_DATA(pnd)->port); uart_close(DRIVER_DATA(pnd)->port);
nfc_device_free(pnd);
return NULL; return NULL;
} }
#else #else

View file

@ -98,6 +98,7 @@ pn532_uart_scan(const nfc_context *context, nfc_connstring connstrings[], const
if (!pnd->driver_data) { if (!pnd->driver_data) {
perror("malloc"); perror("malloc");
uart_close(sp); uart_close(sp);
nfc_device_free(pnd);
return 0; return 0;
} }
DRIVER_DATA(pnd)->port = sp; DRIVER_DATA(pnd)->port = sp;
@ -113,6 +114,7 @@ pn532_uart_scan(const nfc_context *context, nfc_connstring connstrings[], const
// pipe-based abort mecanism // pipe-based abort mecanism
if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) { if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) {
uart_close(DRIVER_DATA(pnd)->port); uart_close(DRIVER_DATA(pnd)->port);
nfc_device_free(pnd);
return 0; return 0;
} }
#else #else
@ -222,6 +224,7 @@ pn532_uart_open(const nfc_context *context, const nfc_connstring connstring)
if (!pnd->driver_data) { if (!pnd->driver_data) {
perror("malloc"); perror("malloc");
uart_close(sp); uart_close(sp);
nfc_device_free(pnd);
return NULL; return NULL;
} }
DRIVER_DATA(pnd)->port = sp; DRIVER_DATA(pnd)->port = sp;
@ -241,6 +244,7 @@ pn532_uart_open(const nfc_context *context, const nfc_connstring connstring)
// pipe-based abort mecanism // pipe-based abort mecanism
if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) { if (pipe(DRIVER_DATA(pnd)->iAbortFds) < 0) {
uart_close(DRIVER_DATA(pnd)->port); uart_close(DRIVER_DATA(pnd)->port);
nfc_device_free(pnd);
return NULL; return NULL;
} }
#else #else