netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: wwan: iosm: Properly check for valid exec stage in ipc_mmio_init()
@ 2024-12-29 16:46 Maciej S. Szmigiero
  2024-12-29 16:46 ` [PATCH 2/2] net: wwan: iosm: Fix hibernation by re-binding the driver around it Maciej S. Szmigiero
  2025-01-03  2:50 ` [PATCH 1/2] net: wwan: iosm: Properly check for valid exec stage in ipc_mmio_init() patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Maciej S. Szmigiero @ 2024-12-29 16:46 UTC (permalink / raw)
  To: M Chetan Kumar, Loic Poulain, Sergey Ryazanov, Johannes Berg
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev, linux-kernel

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: dc0514f5d828 ("net: iosm: mmio scratchpad")
Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
---
 drivers/net/wwan/iosm/iosm_ipc_mmio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wwan/iosm/iosm_ipc_mmio.c b/drivers/net/wwan/iosm/iosm_ipc_mmio.c
index 63eb08c43c05..6764c13530b9 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_mmio.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_mmio.c
@@ -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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-04 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-29 16:46 [PATCH 1/2] net: wwan: iosm: Properly check for valid exec stage in ipc_mmio_init() Maciej S. Szmigiero
2024-12-29 16:46 ` [PATCH 2/2] net: wwan: iosm: Fix hibernation by re-binding the driver around it Maciej S. Szmigiero
2025-01-04 16:48   ` Jakub Kicinski
2025-01-03  2:50 ` [PATCH 1/2] net: wwan: iosm: Properly check for valid exec stage in ipc_mmio_init() patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).