]> xenbits.xensource.com Git - xen.git/commitdiff
tmem: Prevent NULL dereference on error case
authorMatthew Daley <mattjd@gmail.com>
Wed, 14 Nov 2012 09:43:14 +0000 (10:43 +0100)
committerMatthew Daley <mattjd@gmail.com>
Wed, 14 Nov 2012 09:43:14 +0000 (10:43 +0100)
If the client / pool IDs given to tmemc_save_get_next_page are invalid,
the calculation of pagesize will dereference NULL.

Fix this by moving the calculation below the appropriate NULL check.

Signed-off-by: Matthew Daley <mattjd@gmail.com>
xen-unstable changeset: 26132:286ef4ced216
xen-unstable date: Mon Nov 12 08:34:57 UTC 2012

xen/common/tmem.c

index 374f41287860b555efe9d9d384e21fde8b9c1507..f1c0468fc31b28a45a9697dba8708f39c0d6f5f1 100644 (file)
@@ -2449,10 +2449,12 @@ static NOINLINE int tmemc_save_get_next_page(int cli_id, uint32_t pool_id,
     OID oid;
     int ret = 0;
     struct tmem_handle h;
-    unsigned int pagesize = 1 << (pool->pageshift+12);
+    unsigned int pagesize;
 
     if ( pool == NULL || is_ephemeral(pool) )
         return -1;
+
+    pagesize = 1 << (pool->pageshift + 12);
     if ( bufsize < pagesize + sizeof(struct tmem_handle) )
         return -ENOMEM;