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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241119121912.12383-3-sean@starlabs.systems>
Date: Tue, 19 Nov 2024 12:19:12 +0000
From: Sean Rhodes <sean@...rlabs.systems>
To: linux-kernel@...r.kernel.org
Cc: Sean Rhodes <sean@...rlabs.systems>,
	Arnd Bergmann <arnd@...db.de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [PATCH 3/3] drivers/card_reader/rtsx_usb: Fix clock switching logic

Fix the `rtsx_usb_switch_clock` function to ensure the `card_clock`
parameter is not inadvertently modified during the function's
execution. This change:
- Introduces a `hardware_clock` variable to store the original clock
  value, preserving the integrity of the `card_clock` parameter.
- Updates the assignment of `ucr->cur_clk` to use `original_card_clock`.

This adjustment aligns the behavior with the intended logic and
prevents unintended side effects from modifying input parameters.

Cc: Arnd Bergmann <arnd@...db.de>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Signed-off-by: Sean Rhodes <sean@...rlabs.systems>
---
 drivers/misc/cardreader/rtsx_usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index 285a748748d7..f5936c021777 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -406,6 +406,7 @@ int rtsx_usb_switch_clock(struct rtsx_ucr *ucr, unsigned int card_clock,
 {
 	int ret;
 	u8 n, clk_divider, mcu_cnt, div;
+	unsigned int original_card_clock = card_clock;
 
 	if (!card_clock) {
 		ucr->cur_clk = 0;
@@ -494,7 +495,7 @@ int rtsx_usb_switch_clock(struct rtsx_ucr *ucr, unsigned int card_clock,
 	if (ret < 0)
 		return ret;
 
-	ucr->cur_clk = card_clock;
+	ucr->cur_clk = original_card_clock;
 
 	return 0;
 }
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ