Skip to contentSkip to conversation

spi: fix finalize message on error return

PATCH In review David Lechner 2 participants 2 messages Jan 25, 2024 – Jan 26, 2024 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: fix finalize message on error return

In __spi_pump_transfer_message(), the message was not finalized in the first error return as it is in the other error return paths. Not finalizing the message could cause anything waiting on the message to complete to hang forever.

This adds the missing call to spi_finalize_current_message().

Fixes ae7d2346dc89 ("spi: Don't use the message queue if possible in spi_sync")

---

Context:

I just noticed that this was missing while looking at the code, so I didn't actually hit the error path here.

Also, technically the bug probably existed before the Fixes commit but that change did some refactoring and moved that particular chunk of code, so that is the oldest commit where this patch will apply cleanly.

 drivers/spi/spi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/spi/spi.c +4 -0
index 7a70ef47cdf6..4dea33ca50b9 100644
@@ -1717,6 +1717,10 @@ static int __spi_pump_transfer_message(struct spi_controller *ctlr,
 			pm_runtime_put_noidle(ctlr->dev.parent);
 			dev_err(&ctlr->dev, "Failed to power device: %d\n",
 				ret);
+
+			msg->status = ret;
+			spi_finalize_current_message(ctlr);
+
 			return ret;
 		}
 	}
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 8 lines · David Lechner

In __spi_pump_transfer_message(), the message was not finalized in the first error return as it is in the other error return paths. Not finalizing the message could cause anything waiting on the message to complete to hang forever.

This adds the missing call to spi_finalize_current_message().

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: fix finalize message on error return

      commit: 8c2ae772fe08e33f3d7a83849e85539320701abd

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark