nfctype2: Fix possible NULL pointer dereference in data_write
authorSzymon Janc <szymon.janc@tieto.com>
Tue, 7 Aug 2012 12:22:28 +0000 (14:22 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 14 Aug 2012 15:13:49 +0000 (17:13 +0200)
Check if memory allocation succeed before dereferencing pointer.

plugins/nfctype2.c

index 4a9405d..50ae94f 100644 (file)
@@ -390,6 +390,9 @@ static int data_write(uint32_t adapter_idx, uint32_t target_idx,
        DBG("");
 
        cookie = g_try_malloc0(sizeof(struct t2_cookie));
+       if (cookie == NULL)
+               return -ENOMEM;
+
        cookie->adapter_idx = adapter_idx;
        cookie->target_idx = target_idx;
        cookie->current_block = DATA_BLOCK_START;