Skip to content

Commit b51c1e8

Browse files
bleungatchromiumgregkh
authored andcommitted
usb: typec: thunderbolt: Fix loops that iterate TYPEC_PLUG_SOP_P and TYPEC_PLUG_SOP_PP
Fixes these Smatch static checker warnings: drivers/usb/typec/altmodes/thunderbolt.c:116 tbt_altmode_work() warn: why is zero skipped 'i' drivers/usb/typec/altmodes/thunderbolt.c:147 tbt_enter_modes_ordered() warn: why is zero skipped 'i' drivers/usb/typec/altmodes/thunderbolt.c:328 tbt_altmode_remove() warn: why is zero skipped 'i' Fixes: 100e257 ("usb: typec: Add driver for Thunderbolt 3 Alternate Mode") Signed-off-by: Benson Leung <[email protected]> Reported-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]>
1 parent 51333bf commit b51c1e8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/usb/typec/altmodes/thunderbolt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void tbt_altmode_work(struct work_struct *work)
112112
return;
113113

114114
disable_plugs:
115-
for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) {
115+
for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) {
116116
if (tbt->plug[i])
117117
typec_altmode_put_plug(tbt->plug[i]);
118118

@@ -143,7 +143,7 @@ static int tbt_enter_modes_ordered(struct typec_altmode *alt)
143143
if (tbt->plug[TYPEC_PLUG_SOP_P]) {
144144
ret = typec_cable_altmode_enter(alt, TYPEC_PLUG_SOP_P, NULL);
145145
if (ret < 0) {
146-
for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) {
146+
for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) {
147147
if (tbt->plug[i])
148148
typec_altmode_put_plug(tbt->plug[i]);
149149

@@ -324,7 +324,7 @@ static void tbt_altmode_remove(struct typec_altmode *alt)
324324
{
325325
struct tbt_altmode *tbt = typec_altmode_get_drvdata(alt);
326326

327-
for (int i = TYPEC_PLUG_SOP_PP; i > 0; --i) {
327+
for (int i = TYPEC_PLUG_SOP_PP; i >= 0; --i) {
328328
if (tbt->plug[i])
329329
typec_altmode_put_plug(tbt->plug[i]);
330330
}

0 commit comments

Comments
 (0)