lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <d4e3550f-3c50-41f8-a6ed-dd689b2ae868@web.de>
Date: Mon, 23 Sep 2024 17:17:29 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: nvdimm@...ts.linux.dev, kernel-janitors@...r.kernel.org,
 Dan Williams <dan.j.williams@...el.com>, Dave Jiang <dave.jiang@...el.com>,
 Ira Weiny <ira.weiny@...el.com>, Vishal Verma <vishal.l.verma@...el.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] nvdimm: Call nvdimm_put_key(key) only once in
 nvdimm_key_revalidate()

From: Markus Elfring <elfring@...rs.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@...rs.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ