Skip to contentSkip to conversation

keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()

PATCH New [email protected] 1 participant 1 message Jan 15, 2021

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

PATCH 1/1 keys: crypto: Replace BUG_ON() with WARN() in find_asymmetric_key()

From: Jarkko Sakkinen <[email protected]>

BUG_ON() should not be used in the kernel code, unless there are exceptional reasons to do so. Replace BUG_ON() with WARN() and return.

Fixes b3811d36a3e7 ("KEYS: checking the input id parameters before finding asymmetric key")
---
 crypto/asymmetric_keys/asymmetric_type.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
crypto/asymmetric_keys/asymmetric_type.c +4 -1
index 33e77d846caa..47cc88fa0fa7 100644
@@ -54,7 +54,10 @@ struct key *find_asymmetric_key(struct key *keyring,
 	char *req, *p;
 	int len;
 
-	BUG_ON(!id_0 && !id_1);
+	if (!id_0 && !id_1) {
+		WARN(1, "All ID's are NULL\n");
+		return ERR_PTR(-EINVAL);
+	}
 
 	if (id_0) {
 		lookup = id_0->data;
Signature · 1 line
2.29.2