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

plugins/nfctype2.c

index d268011..e5cf764 100644 (file)
@@ -275,6 +275,9 @@ static int nfctype2_read_meta(uint32_t adapter_idx, uint32_t target_idx,
        cmd.block = META_BLOCK_START;
 
        cookie = g_try_malloc0(sizeof(struct t2_cookie));
+       if (cookie == NULL)
+               return -ENOMEM;
+
        cookie->adapter_idx = adapter_idx;
        cookie->target_idx = target_idx;
        cookie->cb = cb;