Skip to contentSkip to conversation

crypto: fix missing unlock on error in sun4i_hash()

PATCH Superseded Wei Yongjun 3 participants 5 messages Aug 18, 2016 – Aug 24, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: fix missing unlock on error in sun4i_hash()

Add the missing unlock before return from function sun4i_hash() in the error handling case.

Fixes 477d9b2e591b ("crypto: sun4i-ss - unify update/final function")
---
 drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 1 +
 1 file changed, 1 insertion(+)
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +1 -0
index 2ee3b59..de66f47 100644
@@ -245,6 +245,7 @@ int sun4i_hash(struct ahash_request *areq)
 		if (end > areq->nbytes || areq->nbytes - end > 63) {
 			dev_err(ss->dev, "ERROR: Bound error %u %u\n",
 				end, areq->nbytes);
+			spin_unlock(&ss->slock);
 			return -EINVAL;
 		}
 	} else {
#1 lore raw

PATCH 1/1 crypto: fix missing unlock on error in sun4i_hash()

Quoted 15 lines · Wei Yongjun

Add the missing unlock before return from function sun4i_hash() in the error handling case.

Fixes 477d9b2e591b ("crypto: sun4i-ss - unify update/final function")
---
 drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 1 +
 1 file changed, 1 insertion(+)
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +0 -0
index 2ee3b59..de66f47 100644

drivers/crypto/sunxi-ss/sun4i-ss-hash.c int sun4i_hash(struct ahash_request *areq) · line 251

Quoted 7 lines
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +1 -0
@@ -245,6 +245,7 @@ int sun4i_hash(struct ahash_request *areq)
 		if (end > areq->nbytes || areq->nbytes - end > 63) {
 			dev_err(ss->dev, "ERROR: Bound error %u %u\n",
 				end, areq->nbytes);
+			spin_unlock(&ss->slock);
 			return -EINVAL;
 		}
 	} else {

Hello

Thanks for the finding, but it is better in that case to use the goto release_ss since it need also to stop the device.

Regards

LABBE Corentin

#2 lore raw

PATCH v2 1/1 crypto: sun4i-ss - fix missing unlock on error in sun4i_hash()

In reply to Wei Yongjun

Add the missing unlock before return from function sun4i_hash() in the error handling case.

Fixes 477d9b2e591b ("crypto: sun4i-ss - unify update/final function")

---
v1 -> v2: goto release_ss as LABBE Corentin's suggestion

---
 drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +2 -1
index 2ee3b59..1afeb8e 100644
@@ -245,7 +245,8 @@ int sun4i_hash(struct ahash_request *areq)
 		if (end > areq->nbytes || areq->nbytes - end > 63) {
 			dev_err(ss->dev, "ERROR: Bound error %u %u\n",
 				end, areq->nbytes);
-			return -EINVAL;
+			err = -EINVAL;
+			goto release_ss;
 		}
 	} else {
 		/* Since we have the flag final, we can go up to modulo 4 */
#3 lore raw

PATCH v2 1/1 crypto: sun4i-ss - fix missing unlock on error in sun4i_hash()

Quoted 17 lines · Wei Yongjun

Add the missing unlock before return from function sun4i_hash() in the error handling case.

Fixes 477d9b2e591b ("crypto: sun4i-ss - unify update/final function")

---
v1 -> v2: goto release_ss as LABBE Corentin's suggestion

---
 drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +0 -0
index 2ee3b59..1afeb8e 100644

drivers/crypto/sunxi-ss/sun4i-ss-hash.c int sun4i_hash(struct ahash_request *areq) · line 252

Quoted 9 lines
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +2 -1
@@ -245,7 +245,8 @@ int sun4i_hash(struct ahash_request *areq)
 		if (end > areq->nbytes || areq->nbytes - end > 63) {
 			dev_err(ss->dev, "ERROR: Bound error %u %u\n",
 				end, areq->nbytes);
-			return -EINVAL;
+			err = -EINVAL;
+			goto release_ss;
 		}
 	} else {
 		/* Since we have the flag final, we can go up to modulo 4 */

Thanks

maintainer
#4 lore raw

PATCH v2 1/1 crypto: sun4i-ss - fix missing unlock on error in sun4i_hash()

In reply to Wei Yongjun
Quoted 5 lines · Wei Yongjun

Add the missing unlock before return from function sun4i_hash() in the error handling case.

Fixes 477d9b2e591b ("crypto: sun4i-ss - unify update/final function")

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt