mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: nvdimm@lists.linux.dev, kernel-janitors@vger.kernel.org,
	Dan Williams <dan.j.williams@intel.com>,
	Dave Jiang <dave.jiang@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] nvdimm: Call nvdimm_put_key(key) only once in nvdimm_key_revalidate()
Date: Mon, 23 Sep 2024 17:17:29 +0200	[thread overview]
Message-ID: <d4e3550f-3c50-41f8-a6ed-dd689b2ae868@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 23 Sep 2024 17:05:39 +0200

A nvdimm_put_key(key) call was immediately used after a return code
check for a change_key() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/nvdimm/security.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c
index a03e3c45f297..83c30980307c 100644
--- a/drivers/nvdimm/security.c
+++ b/drivers/nvdimm/security.c
@@ -152,12 +152,10 @@ static int nvdimm_key_revalidate(struct nvdimm *nvdimm)
 	 * verify that the key is good.
 	 */
 	rc = nvdimm->sec.ops->change_key(nvdimm, data, data, NVDIMM_USER);
-	if (rc < 0) {
-		nvdimm_put_key(key);
+	nvdimm_put_key(key);
+	if (rc < 0)
 		return rc;
-	}

-	nvdimm_put_key(key);
 	nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
 	return 0;
 }
--
2.46.1


                 reply	other threads:[~2024-09-23 15:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4e3550f-3c50-41f8-a6ed-dd689b2ae868@web.de \
    --to=markus.elfring@web.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®