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>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 15 Jul 2022 22:48:07 +1000
From:   Daniil Lunev <dlunev@...omium.org>
To:     Adrian Hunter <adrian.hunter@...el.com>
Cc:     Daniil Lunev <dlunev@...omium.org>,
        Avri Altman <avri.altman@....com>,
        Bart Van Assche <bvanassche@....org>,
        Bean Huo <beanhuo@...ron.com>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org
Subject: [PATCH] scsi: ufs: ufs-pci: Correct check for RESET DSM

dsm_fns is a bitmap, and it is 0-indexed according to the check in
__intel_dsm funciton. But common initialization was checking it as if it
was 1-indexed. The CL corrects the discrepancy. This change won't break
any existing calls to the function, since before the change both bits 0
and 1 were checked and needed to be set.

Signed-off-by: Daniil Lunev <dlunev@...omium.org>

---

 drivers/ufs/host/ufshcd-pci.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/host/ufshcd-pci.c b/drivers/ufs/host/ufshcd-pci.c
index 04166bda41daa..e54a49e64acad 100644
--- a/drivers/ufs/host/ufshcd-pci.c
+++ b/drivers/ufs/host/ufshcd-pci.c
@@ -20,6 +20,12 @@
 #include <linux/acpi.h>
 #include <linux/gpio/consumer.h>
 
+#define __INTEL_DSM_SUPPORTED(host, fn) \
+	((fn) < 32 && (fn) >= 0 && ((host)->dsm_fns & (1 << (fn))))
+
+#define INTEL_DSM_SUPPORTED(host, name) \
+	__INTEL_DSM_SUPPORTED(host, INTEL_DSM_##name)
+
 struct ufs_host {
 	void (*late_init)(struct ufs_hba *hba);
 };
@@ -71,7 +77,7 @@ static int __intel_dsm(struct intel_host *intel_host, struct device *dev,
 static int intel_dsm(struct intel_host *intel_host, struct device *dev,
 		     unsigned int fn, u32 *result)
 {
-	if (fn > 31 || !(intel_host->dsm_fns & (1 << fn)))
+	if (!__INTEL_DSM_SUPPORTED(intel_host, fn))
 		return -EOPNOTSUPP;
 
 	return __intel_dsm(intel_host, dev, fn, result);
@@ -300,7 +306,7 @@ static int ufs_intel_device_reset(struct ufs_hba *hba)
 {
 	struct intel_host *host = ufshcd_get_variant(hba);
 
-	if (host->dsm_fns & INTEL_DSM_RESET) {
+	if (INTEL_DSM_SUPPORTED(host, RESET)) {
 		u32 result = 0;
 		int err;
 
@@ -342,7 +348,7 @@ static int ufs_intel_common_init(struct ufs_hba *hba)
 		return -ENOMEM;
 	ufshcd_set_variant(hba, host);
 	intel_dsm_init(host, hba->dev);
-	if (host->dsm_fns & INTEL_DSM_RESET) {
+	if (INTEL_DSM_SUPPORTED(host, RESET)) {
 		if (hba->vops->device_reset)
 			hba->caps |= UFSHCD_CAP_DEEPSLEEP;
 	} else {
-- 
2.31.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ