summaryrefslogtreecommitdiff
path: root/drivers/crypto/chelsio/chtls/chtls_main.c
diff options
context:
space:
mode:
authorGanesh Goudar <ganeshgr@chelsio.com>2018-08-10 18:27:41 +0530
committerHerbert Xu <herbert@gondor.apana.org.au>2018-08-25 19:50:41 +0800
commit65b2c12dcdb883fc015c0ec65d6c2f857e0456ac (patch)
treef55627a7acd67cc611d70e6e55daa6faa610861e /drivers/crypto/chelsio/chtls/chtls_main.c
parent7fa885e2a22fd0f91a2c23d9275f5021f618ff5a (diff)
downloadlwn-65b2c12dcdb883fc015c0ec65d6c2f857e0456ac.tar.gz
lwn-65b2c12dcdb883fc015c0ec65d6c2f857e0456ac.zip
crypto: chtls - fix null dereference chtls_free_uld()
call chtls_free_uld() only for the initialized cdev, this fixes NULL dereference in chtls_free_uld() Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com> Signed-off-by: Atul Gupta <atul.gupta@chelsio.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/chelsio/chtls/chtls_main.c')
-rw-r--r--drivers/crypto/chelsio/chtls/chtls_main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c
index 9b07f9165658..f59b044ebd25 100644
--- a/drivers/crypto/chelsio/chtls/chtls_main.c
+++ b/drivers/crypto/chelsio/chtls/chtls_main.c
@@ -160,6 +160,7 @@ static void chtls_register_dev(struct chtls_dev *cdev)
tlsdev->hash = chtls_create_hash;
tlsdev->unhash = chtls_destroy_hash;
tls_register_device(&cdev->tlsdev);
+ cdev->cdev_state = CHTLS_CDEV_STATE_UP;
}
static void chtls_unregister_dev(struct chtls_dev *cdev)
@@ -281,8 +282,10 @@ static void chtls_free_all_uld(void)
struct chtls_dev *cdev, *tmp;
mutex_lock(&cdev_mutex);
- list_for_each_entry_safe(cdev, tmp, &cdev_list, list)
- chtls_free_uld(cdev);
+ list_for_each_entry_safe(cdev, tmp, &cdev_list, list) {
+ if (cdev->cdev_state == CHTLS_CDEV_STATE_UP)
+ chtls_free_uld(cdev);
+ }
mutex_unlock(&cdev_mutex);
}