Skip to content

spi-bcm2835: Always initialize local variable in bcm2835_wr_fifo_count - #3000

Closed
mbuesch wants to merge 1 commit into
raspberrypi:rpi-5.2.yfrom
mbuesch:mb-rpi-5.2.y-spifix
Closed

mbuesch wants to merge 1 commit into
raspberrypi:rpi-5.2.yfrom
mbuesch:mb-rpi-5.2.y-spifix

Conversation

@mbuesch

@mbuesch mbuesch commented Jun 4, 2019

Copy link
Copy Markdown
Contributor

If count is less than 4 and memcpy copies less than 4 bytes into var,
some bytes remain uninitialized. These uninitialized bytes are taken
from var and written to the BCM2835_SPI_FIFO register.

While the hardware probably is able to ignore these extra bytes, it's
Undefined Behavior to read uninitialized bytes. So don't do that.

If count is less than 4 and memcpy copies less than 4 bytes into var,
some bytes remain uninitialized. These uninitialized bytes are taken
from var and written to the BCM2835_SPI_FIFO register.

While the hardware probably is able to ignore these extra bytes, it's
Undefined Behavior to read uninitialized bytes. So don't do that.

Signed-off-by: Michael Buesch <m@bues.ch>
@popcornmix

Copy link
Copy Markdown
Collaborator

The fix looks correct to me. But this is an upstream kernel file, so it really needs to be fixed there (we will get the fix once it's accepted there).

See: https://kernelnewbies.org/UpstreamMerge/SubmittingPatches

@mbuesch

mbuesch commented Jun 5, 2019

Copy link
Copy Markdown
Contributor Author

Thanks @popcornmix.
I was unsure how modifications to these upstream files work. Thanks for explaining it to me.
I'll submit this patch upstream and CC stable, if required.

@mbuesch mbuesch closed this Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants