Skip to contentSkip to conversation

phy: usb: sunplus: Fix return value check in update_disc_vol()

PATCH Applied Wei Yongjun 2 participants 2 messages Sep 9, 2022 – Sep 13, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: usb: sunplus: Fix return value check in update_disc_vol()

From: Wei Yongjun <[email protected]>

In case of error, the function nvmem_cell_read() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes 99d9ccd97385 ("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
---
 drivers/phy/sunplus/phy-sunplus-usb2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/sunplus/phy-sunplus-usb2.c +2 -2
index 5269968b3060..b932087c55b2 100644
@@ -92,13 +92,13 @@ 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;
 	}
 
-	if (!otp_v || set == 0)
+	if (IS_ERR(otp_v) || set == 0)
 		set = OTP_DISC_LEVEL_DEFAULT;
 
 	val = readl(usbphy->phy_regs + CONFIG7);
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
maintainer Applied
#1 lore raw
Quoted 5 lines · Wei Yongjun

From: Wei Yongjun <[email protected]>

In case of error, the function nvmem_cell_read() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Applied, thanks

Signature · 6 lines
~Vinod

-- 
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy