From patchwork Tue Dec 21 15:28:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 424601 X-Patchwork-Delegate: agk@redhat.com Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBLFUYN8001620 for ; Tue, 21 Dec 2010 15:30:55 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oBLFSubQ015318; Tue, 21 Dec 2010 10:28:57 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oBLFStjc005290 for ; Tue, 21 Dec 2010 10:28:55 -0500 Received: from tawny.mazyland.cz (tawny.brq.redhat.com [10.34.26.53]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBLFSSbv028030; Tue, 21 Dec 2010 10:28:49 -0500 From: Milan Broz To: dm-devel@redhat.com Date: Tue, 21 Dec 2010 16:28:13 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-loop: dm-devel@redhat.com Cc: Milan Broz Subject: [dm-devel] [PATCH 1/7] dm crypt: fix per cpu struct dereference in destructor X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 21 Dec 2010 15:30:55 +0000 (UTC) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 98a7ad0..6aeb1fe 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1088,7 +1088,6 @@ static int crypt_setkey_allcpus(struct crypt_config *cc) return err; } - static int crypt_set_key(struct crypt_config *cc, char *key) { unsigned key_size = strlen(key) >> 1; @@ -1114,20 +1113,6 @@ static int crypt_wipe_key(struct crypt_config *cc) return crypt_setkey_allcpus(cc); } -static void crypt_dtr_cpus(struct crypt_config *cc) -{ - struct crypt_cpu *cs; - int cpu; - - for_each_possible_cpu(cpu) { - cs = per_cpu_ptr(cc->cpu, cpu); - if (cs->tfm) { - crypto_free_ablkcipher(cs->tfm); - cs->tfm = NULL; - } - } -} - static void crypt_dtr(struct dm_target *ti) { struct crypt_config *cc = ti->private; @@ -1144,11 +1129,14 @@ static void crypt_dtr(struct dm_target *ti) if (cc->crypt_queue) destroy_workqueue(cc->crypt_queue); - for_each_possible_cpu(cpu) { - cs = per_cpu_ptr(cc->cpu, cpu); - if (cs->req) - mempool_free(cs->req, cc->req_pool); - } + if (cc->cpu) + for_each_possible_cpu(cpu) { + cs = per_cpu_ptr(cc->cpu, cpu); + if (cs->req) + mempool_free(cs->req, cc->req_pool); + if (cs->tfm) + crypto_free_ablkcipher(cs->tfm); + } if (cc->bs) bioset_free(cc->bs); @@ -1166,8 +1154,6 @@ static void crypt_dtr(struct dm_target *ti) if (cc->dev) dm_put_device(ti, cc->dev); - crypt_dtr_cpus(cc); - if (cc->cpu) free_percpu(cc->cpu);