Skip to contentSkip to conversation

crypto: x509_loader: Use %pe to log error pointer

PATCH In review Muhammad Mahdi Amirpour 2 participants 2 messages Oct 15 – Nov 6

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

PATCH 1/1 crypto: x509_loader: Use %pe to log error pointer

The error path in x509_load_certificate_list() prints an error pointer with %ld and PTR_ERR(), which produces a raw errno value rather than the kernel's symbolic error name.

Use %pe on the error pointer directly so the log reads:

Problem loading in-kernel X.509 certificate (EINVAL)

instead of:

Problem loading in-kernel X.509 certificate (-22)

The new form is easier to read and matches the convention used elsewhere in the kernel. Reported by Coccinelle's misc/ptr_err_to_pe.cocci semantic patch.

---
 crypto/asymmetric_keys/x509_loader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
crypto/asymmetric_keys/x509_loader.c +2 -2
index 0d516c77cc2..373b5106e10 100644
@@ -39,8 +39,8 @@ int x509_load_certificate_list(const u8 cert_list[],
 					   KEY_ALLOC_BUILT_IN |
 					   KEY_ALLOC_BYPASS_RESTRICTION);
 		if (IS_ERR(key)) {
-			pr_err("Problem loading in-kernel X.509 certificate (%ld)\n",
-			       PTR_ERR(key));
+			pr_err("Problem loading in-kernel X.509 certificate (%pe)\n",
+			       key);
 		} else {
 			pr_notice("Loaded X.509 cert '%s'\n",
 				  key_ref_to_ptr(key)->description);
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 12 lines · Muhammad Mahdi Amirpour

The error path in x509_load_certificate_list() prints an error pointer with %ld and PTR_ERR(), which produces a raw errno value rather than the kernel's symbolic error name.

Use %pe on the error pointer directly so the log reads:

Problem loading in-kernel X.509 certificate (EINVAL)

instead of:

Problem loading in-kernel X.509 certificate (-22)

Quoted 8 lines

The new form is easier to read and matches the convention used elsewhere in the kernel. Reported by Coccinelle's misc/ptr_err_to_pe.cocci semantic patch.

---
 crypto/asymmetric_keys/x509_loader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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