Skip to content

Commit

Permalink
net: wwan: iosm: Properly check for valid exec stage in ipc_mmio_init()
Browse files Browse the repository at this point in the history
ipc_mmio_init() used the post-decrement operator in its loop continuing
condition of "retries" counter being "> 0", which meant that when this
condition caused loop exit "retries" counter reached -1.

But the later valid exec stage failure check only tests for "retries"
counter being exactly zero, so it didn't trigger in this case (but
would wrongly trigger if the code reaches a valid exec stage in the
very last loop iteration).

Fix this by using the pre-decrement operator instead, so the loop counter
is exactly zero on valid exec stage failure.

Fixes: dc0514f ("net: iosm: mmio scratchpad")
Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Link: https://patch.msgid.link/8b19125a825f9dcdd81c667c1e5c48ba28d505a6.1735490770.git.mail@maciej.szmigiero.name
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Maciej S. Szmigiero authored and Jakub Kicinski committed Jan 3, 2025
1 parent 5b0af62 commit a7af435
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/wwan/iosm/iosm_ipc_mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct iosm_mmio *ipc_mmio_init(void __iomem *mmio, struct device *dev)
break;

msleep(20);
} while (retries-- > 0);
} while (--retries > 0);

if (!retries) {
dev_err(ipc_mmio->dev, "invalid exec stage %X", stage);
Expand Down

0 comments on commit a7af435

Please sign in to comment.