spi: tegra210-quad: Fix iterator outside loop
Subsystems (4)
PATCH 1/1 spi: tegra210-quad: Fix iterator outside loop
Fix warn: iterator used outside loop: 'xfer'
xfer variable may contain invalid value in few conditions. Move transfer complete check within list loop.
--- drivers/spi/spi-tegra210-quad.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/spi/spi-tegra210-quad.c +4 -4
@@ -1178,12 +1178,12 @@ static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, goto exit; } msg->actual_length += xfer->len; +if (!xfer->cs_change && transfer_phase ==DATA_TRANSFER ) { +tegra_qspi_transfer_end (spi); +spi_transfer_delay_exec (xfer); + } transfer_phase++; } -if (!xfer->cs_change) { -tegra_qspi_transfer_end (spi); -spi_transfer_delay_exec (xfer); - } ret =0 ; exit:
Signature · 1 line
2.17.1
Mark Brown
maintainerdrivers/spi/spi-tegra210-quad.c static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, · line 1186
Quoted 11 lines · Krishna Yarlagadda
drivers/spi/spi-tegra210-quad.c +4
-4msg->actual_length += xfer->len; +if (!xfer->cs_change && transfer_phase ==DATA_TRANSFER ) { +tegra_qspi_transfer_end (spi); +spi_transfer_delay_exec (xfer); + } transfer_phase++; } -if (!xfer->cs_change) { -tegra_qspi_transfer_end (spi); -spi_transfer_delay_exec (xfer); - }
This looks like it'll do the wrong thing and do a change on every transfer if cs_change isn't set?
Quoted 16 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: 24 February 2023 22:17
To: Krishna Yarlagadda <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Jonathan Hunter <[email protected]>; Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>
Subject: Re: [PATCH] spi: tegra210-quad: Fix iterator outside loopReview
Quoted 2 lines · Krishna Yarlagadda
(quoted diff) +1
-0msg->actual_length += xfer->len; + if (!xfer->cs_change && transfer_phase == DATA_TRANSFER){
Quoted 12 lines
drivers/spi/spi-tegra210-quad.c static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, · line 1186
Quoted 9 lines
drivers/spi/spi-tegra210-quad.c +3
-4+tegra_qspi_transfer_end (spi); +spi_transfer_delay_exec (xfer); + } transfer_phase++; } -if (!xfer->cs_change) { -tegra_qspi_transfer_end (spi); -spi_transfer_delay_exec (xfer); - }This looks like it'll do the wrong thing and do a change on every transfer if
cs_changeisn't set?
This condition is hit only in data phase which is end of message. KY
Mark Brown
maintainerQuoted 16 lines · Krishna Yarlagadda
Quoted 15 lines
Review
Quoted 2 lines
(quoted diff) +1
-0msg->actual_length += xfer->len; + if (!xfer->cs_change && transfer_phase == DATA_TRANSFER){
drivers/spi/spi-tegra210-quad.c static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, · line 1186
Quoted 9 lines
drivers/spi/spi-tegra210-quad.c +3
-4+tegra_qspi_transfer_end (spi); +spi_transfer_delay_exec (xfer); + } transfer_phase++; } -if (!xfer->cs_change) { -tegra_qspi_transfer_end (spi); -spi_transfer_delay_exec (xfer); - }This looks like it'll do the wrong thing and do a change on every transfer if
cs_changeisn't set?
Quoted 1 line
This condition is hit only in data phase which is end of message.
Shouldn't this just be moved into the DATA_TRANSFER case statement?
Quoted 25 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: 24 February 2023 23:26
To: Krishna Yarlagadda <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Jonathan Hunter <[email protected]>; Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>
Subject: Re: [PATCH] spi: tegra210-quad: Fix iterator outside loopQuoted 12 lines · Krishna Yarlagadda
Quoted 12 lines
Review
Quoted 2 lines
(quoted diff) +1
-0msg->actual_length += xfer->len; + if (!xfer->cs_change && transfer_phase == DATA_TRANSFER){
drivers/spi/spi-tegra210-quad.c static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, · line 1186
Quoted 9 lines
drivers/spi/spi-tegra210-quad.c +3
-4+tegra_qspi_transfer_end (spi); +spi_transfer_delay_exec (xfer); + } transfer_phase++; } -if (!xfer->cs_change) { -tegra_qspi_transfer_end (spi); -spi_transfer_delay_exec (xfer); - }updating the length of the message.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
This looks like it'll do the wrong thing and do a change on every transfer if
cs_changeisn't set?This condition is hit only in data phase which is end of message.
Shouldn't this just be moved into the
DATA_TRANSFERcase statement?
Calling transfer_end after updating message length.
Mark Brown
maintainerQuoted 5 lines · Krishna Yarlagadda
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi-tegra210-quad.c static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, · line 1186
Quoted 4 lines
drivers/spi/spi-tegra210-quad.c +0
-4-if (!xfer->cs_change) { -tegra_qspi_transfer_end (spi); -spi_transfer_delay_exec (xfer); - }updating the length of the message.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
This looks like it'll do the wrong thing and do a change on every transfer if
cs_changeisn't set?This condition is hit only in data phase which is end of message.
Shouldn't this just be moved into the
DATA_TRANSFERcase statement?Calling
transfer_endafter updating message length.
Something seems to be mangled with your quoting/new text here so it's a bit unclear what you're saying here but if you're saying that this is due to needing to call tegra_qspi_transfer_end() after updating the length I'm not sure why - AFAICT that function doesn't reference the transfer length at all, it just writes out a command to configure the chip select? There's no issue with the message being finalised since that happens in the caller.
Quoted 25 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: 27 February 2023 23:53
To: Krishna Yarlagadda <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; Jonathan Hunter <[email protected]>; Sowjanya Komatineni <[email protected]>; Laxman Dewangan <[email protected]>
Subject: Re: [PATCH] spi: tegra210-quad: Fix iterator outside loopQuoted 5 lines · Krishna Yarlagadda
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
drivers/spi/spi-tegra210-quad.c static int tegra_qspi_combined_seq_xfer(struct tegra_qspi *tqspi, · line 1186
Quoted 4 lines
drivers/spi/spi-tegra210-quad.c +0
-4-if (!xfer->cs_change) { -tegra_qspi_transfer_end (spi); -spi_transfer_delay_exec (xfer); - }updating the length of the message.
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
This looks like it'll do the wrong thing and do a change on every transfer if
cs_changeisn't set?This condition is hit only in data phase which is end of message.
Shouldn't this just be moved into the
DATA_TRANSFERcase statement?Calling
transfer_endafter updating message length.
Quoted 7 lines
Something seems to be mangled with your quoting/new text here so it's a bit unclear what you're saying here but if you're saying that this is due to needing to call
tegra_qspi_transfer_end()after updating the length I'm not sure why - AFAICT that function doesn't reference the transfer length at all, it just writes out a command to configure the chip select? There's no issue with the message being finalised since that happens in the caller.
Yes. Length should not matter. Will move into DATA_TRANSFER case. Also need to handle error case.
Mark Brown
maintainerQuoted 9 lines · Krishna Yarlagadda
Fix warn: iterator used outside loop: 'xfer'
xfer variable may contain invalid value in few conditions. Move transfer complete check within list loop.Reported-by Dan Carpenter <[email protected]>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