diff mbox series

libnvdimm: add warning output when request_key() fails

Message ID 153937866114.12317.12018314886353779354.stgit@djiang5-desk3.ch.intel.com (mailing list archive)
State New, archived
Headers show
Series libnvdimm: add warning output when request_key() fails | expand

Commit Message

Dave Jiang Oct. 12, 2018, 9:11 p.m. UTC
Provide useful error output when request_key() fails.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/nvdimm/security.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c
index 3a905c58a935..5aacc590b4c0 100644
--- a/drivers/nvdimm/security.c
+++ b/drivers/nvdimm/security.c
@@ -73,11 +73,17 @@  static struct key *nvdimm_request_key(struct nvdimm *nvdimm)
 {
 	struct key *key = NULL;
 	char desc[NVDIMM_KEY_DESC_LEN + sizeof(NVDIMM_PREFIX)];
+	struct device *dev = &nvdimm->dev;
 
 	sprintf(desc, "%s%s", NVDIMM_PREFIX, nvdimm->dimm_id);
 	key = request_key(&key_type_logon, desc, "");
-	if (IS_ERR(key))
+	if (IS_ERR(key)) {
+		if (PTR_ERR(key) == -ENOKEY)
+			dev_warn(dev, "request_key() found no key\n");
+		else
+			dev_warn(dev, "request_key() upcall failed\n");
 		key = NULL;
+	}
 
 	return key;
 }