linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch V2] spi: tegra210-quad: Fix iterator outside loop
@ 2023-02-27 20:04 Krishna Yarlagadda
  2023-02-28 19:14 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Krishna Yarlagadda @ 2023-02-27 20:04 UTC (permalink / raw)
  To: broonie, linux-spi, linux-tegra, linux-kernel
  Cc: thierry.reding, jonathanh, skomatineni, ldewangan, Krishna Yarlagadda

Fix warn: iterator used outside loop: 'xfer'. 'xfer' variable contain
invalid value in few conditions. Complete transfer within DATA phase
in successful case and at the end for failed transfer.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Link:https://lore.kernel.org/all/202210191211.46FkzKmv-lkp@intel.com/
Fixes: 8777dd9dff40 ("spi: tegra210-quad: Fix combined sequence")

Signed-off-by: Krishna Yarlagadda <kyarlagadda@nvidia.com>
---
V2:
 - cs_change check moved to DATA_TRANSFER case
 - transfer_end call in error case

 drivers/spi/spi-tegra210-quad.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c
index 9aaca2289c59..0b9bc3b7f53a 100644
--- a/drivers/spi/spi-tegra210-quad.c
+++ b/drivers/spi/spi-tegra210-quad.c
@@ -1156,6 +1156,10 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
 				ret = -EIO;
 				goto exit;
 			}
+			if (!xfer->cs_change) {
+				tegra_qspi_transfer_end(spi);
+				spi_transfer_delay_exec(xfer);
+			}
 			break;
 		default:
 			ret = -EINVAL;
@@ -1164,14 +1168,14 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi,
 		msg->actual_length += xfer->len;
 		transfer_phase++;
 	}
-	if (!xfer->cs_change) {
-		tegra_qspi_transfer_end(spi);
-		spi_transfer_delay_exec(xfer);
-	}
 	ret = 0;
 
 exit:
 	msg->status = ret;
+	if (ret < 0) {
+		tegra_qspi_transfer_end(spi);
+		spi_transfer_delay_exec(xfer);
+	}
 
 	return ret;
 }
-- 
2.17.1


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

* Re: [Patch V2] spi: tegra210-quad: Fix iterator outside loop
  2023-02-27 20:04 [Patch V2] spi: tegra210-quad: Fix iterator outside loop Krishna Yarlagadda
@ 2023-02-28 19:14 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2023-02-28 19:14 UTC (permalink / raw)
  To: linux-spi, linux-tegra, linux-kernel, Krishna Yarlagadda
  Cc: thierry.reding, jonathanh, skomatineni, ldewangan

On Tue, 28 Feb 2023 01:34:28 +0530, Krishna Yarlagadda wrote:
> Fix warn: iterator used outside loop: 'xfer'. 'xfer' variable contain
> invalid value in few conditions. Complete transfer within DATA phase
> in successful case and at the end for failed transfer.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Link:https://lore.kernel.org/all/202210191211.46FkzKmv-lkp@intel.com/
> Fixes: 8777dd9dff40 ("spi: tegra210-quad: Fix combined sequence")
> 
> [...]

Applied to

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

Thanks!

[1/1] spi: tegra210-quad: Fix iterator outside loop
      commit: 2449d436681d40bc63ec2c766fd51b632270d8a7

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


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

end of thread, other threads:[~2023-02-28 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27 20:04 [Patch V2] spi: tegra210-quad: Fix iterator outside loop Krishna Yarlagadda
2023-02-28 19:14 ` Mark Brown

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).