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]
Message-Id: <1662445382-29879-1-git-send-email-vincent.sunplus@gmail.com>
Date:   Tue,  6 Sep 2022 14:23:02 +0800
From:   Vincent Shih <vincent.sunplus@...il.com>
To:     kishon@...com, vkoul@...nel.org, linux-usb@...r.kernel.org,
        linux-phy@...ts.infradead.org, linux-kernel@...r.kernel.org,
        wells.lu@...plus.com
Cc:     Vincent Shih <vincent.sunplus@...il.com>
Subject: [PATCH] phy: usb: free the buffer after reading a given nvmem cell

Use kfree() to free the buffer after calling nvmem_cell_read() to
read a given nvmem cell.

Fixes:99d9ccd97385("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Signed-off-by: Vincent Shih <vincent.sunplus@...il.com>
---
 drivers/phy/sunplus/phy-sunplus-usb2.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
index 5269968..c8540e1 100644
--- a/drivers/phy/sunplus/phy-sunplus-usb2.c
+++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
@@ -13,6 +13,7 @@
 #include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/nvmem-consumer.h>
@@ -92,13 +93,15 @@ static int update_disc_vol(struct sp_usbphy *usbphy)
 	otp_v = nvmem_cell_read(cell, &otp_l);
 	nvmem_cell_put(cell);
 
-	if (otp_v) {
+	if (!IS_ERR(otp_v)) {
 		set = *(otp_v + 1);
 		set = (set << (sizeof(char) * 8)) | *otp_v;
 		set = (set >> usbphy->disc_vol_addr_off) & J_DISC;
+		
+		kfree(otp_v);
 	}
-
-	if (!otp_v || set == 0)
+	
+	if (IS_ERR(otp_v) || (set == 0))
 		set = OTP_DISC_LEVEL_DEFAULT;
 
 	val = readl(usbphy->phy_regs + CONFIG7);
@@ -294,3 +297,4 @@ module_platform_driver(sunplus_usb_phy_driver);
 MODULE_AUTHOR("Vincent Shih <vincent.shih@...plus.com>");
 MODULE_DESCRIPTION("Sunplus USB 2.0 phy driver");
 MODULE_LICENSE("GPL");
+
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ