Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95f503fc authored by Dinesh K Garg's avatar Dinesh K Garg
Browse files

md: dm-req-crypt does not release the device



dm-req-crypt does not release the device which it got during
construction of dm-req-crypt based node. This causes issue if
dm-req-crypt based device is created and destroyed without
rebooting the device.

Change-Id: Ifeb1210a6e1cf365b8a656556082806a24f3e582
Signed-off-by: default avatarDinesh K Garg <dineshg@codeaurora.org>
parent 3511ae2a
Loading
Loading
Loading
Loading
+16 −29
Original line number Diff line number Diff line
@@ -844,21 +844,13 @@ static void req_crypt_dtr(struct dm_target *ti)
{
	DMDEBUG("dm-req-crypt Destructor.\n");

	if (req_crypt_queue) {
		destroy_workqueue(req_crypt_queue);
		req_crypt_queue = NULL;
	}
	if (req_io_pool) {
		mempool_destroy(req_io_pool);
		req_io_pool = NULL;
	}
	if (req_page_pool) {
		mempool_destroy(req_page_pool);
		req_page_pool = NULL;
	}
	if (tfm) {
		crypto_free_ablkcipher(tfm);
		tfm = NULL;
	if (req_io_pool) {
		mempool_destroy(req_io_pool);
		req_io_pool = NULL;
	}
	mutex_lock(&engine_list_mutex);
	kfree(pfe_eng);
@@ -866,6 +858,16 @@ static void req_crypt_dtr(struct dm_target *ti)
	kfree(fde_eng);
	fde_eng = NULL;
	mutex_unlock(&engine_list_mutex);

	if (tfm) {
		crypto_free_ablkcipher(tfm);
		tfm = NULL;
	}
	if (req_crypt_queue) {
		destroy_workqueue(req_crypt_queue);
		req_crypt_queue = NULL;
	}
	dm_put_device(ti, dev);
}


@@ -1014,24 +1016,9 @@ static int req_crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
	}
	err = 0;
ctr_exit:
	if (err != 0) {
		if (req_crypt_queue) {
			destroy_workqueue(req_crypt_queue);
			req_crypt_queue = NULL;
		}
		if (req_io_pool) {
			mempool_destroy(req_io_pool);
			req_io_pool = NULL;
		}
		if (req_page_pool) {
			mempool_destroy(req_page_pool);
			req_page_pool = NULL;
		}
		if (tfm) {
			crypto_free_ablkcipher(tfm);
			tfm = NULL;
		}
	}
	if (err)
		req_crypt_dtr(ti);

	kfree(eng_list);
	return err;
}