Skip to content

Commit 0529646

Browse files
GONG Ruiqigregkh
authored andcommitted
usb: typec: fix pm usage counter imbalance in ucsi_ccg_sync_control()
commit b0e525d7a22ea350e75e2aec22e47fcfafa4cacd upstream. The error handling for the case `con_index == 0` should involve dropping the pm usage counter, as ucsi_ccg_sync_control() gets it at the beginning. Fix it. Cc: stable <[email protected]> Fixes: e56aac6e5a25 ("usb: typec: fix potential array underflow in ucsi_ccg_sync_control()") Signed-off-by: GONG Ruiqi <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> [Minor context change fixed.] Signed-off-by: Bin Lan <[email protected]> Signed-off-by: He Zhe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e441894 commit 0529646

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/usb/typec/ucsi/ucsi_ccg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static int ucsi_ccg_sync_write(struct ucsi *ucsi, unsigned int offset,
587587
UCSI_CMD_CONNECTOR_MASK;
588588
if (con_index == 0) {
589589
ret = -EINVAL;
590-
goto unlock;
590+
goto err_put;
591591
}
592592
con = &uc->ucsi->connector[con_index - 1];
593593
ucsi_ccg_update_set_new_cam_cmd(uc, con, (u64 *)val);
@@ -603,8 +603,8 @@ static int ucsi_ccg_sync_write(struct ucsi *ucsi, unsigned int offset,
603603

604604
err_clear_bit:
605605
clear_bit(DEV_CMD_PENDING, &uc->flags);
606+
err_put:
606607
pm_runtime_put_sync(uc->dev);
607-
unlock:
608608
mutex_unlock(&uc->lock);
609609

610610
return ret;

0 commit comments

Comments
 (0)