dm thin: fix memory leak in process_prepared_mapping error paths
authorJoe Thornber <ejt@redhat.com>
Fri, 27 Jul 2012 14:08:05 +0000 (15:08 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Fri, 27 Jul 2012 14:08:05 +0000 (15:08 +0100)
Fix memory leak in process_prepared_mapping by always freeing
the dm_thin_new_mapping structs from the mapping_pool mempool on
the error paths.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-thin.c

index 93e3e542cff9c66ad7045310fc93b1deda654cd6..423df92f1c19800307786f716401197c8ba41814 100644 (file)
@@ -870,7 +870,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
 
        if (m->err) {
                cell_error(m->cell);
-               return;
+               goto out;
        }
 
        /*
@@ -882,7 +882,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
        if (r) {
                DMERR("dm_thin_insert_block() failed");
                cell_error(m->cell);
-               return;
+               goto out;
        }
 
        /*
@@ -897,6 +897,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
        } else
                cell_defer(tc, m->cell, m->data_block);
 
+out:
        list_del(&m->list);
        mempool_free(m, tc->pool->mapping_pool);
 }