Skip to contentSkip to conversation

usb: typec: ucsi: ccg: fix missing unlock on error in ccg_cmd_write_flash_row()

PATCH New Heikki Krogerus 3 participants 3 messages Apr 29, 2019

Subsystems (3)
lore
Share & tools
lore

Heikki Krogerus

author maintainer Acked-by
#0 lore raw
Quoted 5 lines · Wei Yongjun

Add the missing unlock before return from function ccg_cmd_write_flash_row() in the error handling case.

Fixes 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support")
Quoted 10 lines
---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +0 -0
index 4632b91a04a6..9d46aa9e4e35 100644

drivers/usb/typec/ucsi/ucsi_ccg.c ccg_cmd_write_flash_row(struct ucsi_ccg *uc, u16 row, · line 637

Quoted 7 lines
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
@@ -631,6 +631,7 @@ ccg_cmd_write_flash_row(struct ucsi_ccg *uc, u16 row,
 	ret = i2c_master_send(client, buf, CCG4_ROW_SIZE + 2);
 	if (ret != CCG4_ROW_SIZE + 2) {
 		dev_err(uc->dev, "REG_FLASH_RW_MEM write fail %d\n", ret);
+		mutex_unlock(&uc->lock);
 		return ret < 0 ? ret : -EIO;
 	}
 

thanks,

Signature · 1 line
heikki
#1 lore raw

PATCH 1/1 usb: typec: ucsi: ccg: fix missing unlock on error in ccg_cmd_write_flash_row()

Add the missing unlock before return from function ccg_cmd_write_flash_row() in the error handling case.

Fixes 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support")
---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
index 4632b91a04a6..9d46aa9e4e35 100644
@@ -631,6 +631,7 @@ ccg_cmd_write_flash_row(struct ucsi_ccg *uc, u16 row,
 	ret = i2c_master_send(client, buf, CCG4_ROW_SIZE + 2);
 	if (ret != CCG4_ROW_SIZE + 2) {
 		dev_err(uc->dev, "REG_FLASH_RW_MEM write fail %d\n", ret);
+		mutex_unlock(&uc->lock);
 		return ret < 0 ? ret : -EIO;
 	}
 
#2 lore raw
In reply to Heikki Krogerus

Hi Wei

Quoted 11 lines

-----Original Message-----
From: Wei Yongjun <[email protected]>
Sent: Monday, April 29, 2019 5:27 AM
To: Heikki Krogerus <[email protected]>; Greg Kroah-Hartman <[email protected]>; Ajay Gupta <[email protected]>; Wolfram Sang <[email protected]>
Cc: Wei Yongjun <[email protected]>; [email protected]; [email protected]
Subject: [PATCH -next] usb: typec: ucsi: ccg: fix missing unlock on error in ccg_cmd_write_flash_row()

Quoted 2 lines

Add the missing unlock before return from function ccg_cmd_write_flash_row() in the error handling case.

Thanks for fixing this. The change looks good.

Quoted 22 lines

nvpublic

Fixes 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support")
---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi_ccg.c +1 -0
index 4632b91a04a6..9d46aa9e4e35 100644
@@ -631,6 +631,7 @@ ccg_cmd_write_flash_row(struct ucsi_ccg *uc, u16 row,
 	ret = i2c_master_send(client, buf, CCG4_ROW_SIZE + 2);
 	if (ret != CCG4_ROW_SIZE + 2) {
 		dev_err(uc->dev, "REG_FLASH_RW_MEM write fail %d\n", ret);
+		mutex_unlock(&uc->lock);
 		return ret < 0 ? ret : -EIO;
 	}