-
Notifications
You must be signed in to change notification settings - Fork 3k
Solving potential null pointer dereference in SpiNorFlashJedecSfdp #10924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving potential null pointer dereference in SpiNorFlashJedecSfdp #10924
Conversation
|
⚠ WARNING: Cannot add some reviewers: A user specified as a reviewer for this PR is not a collaborator of the repository. Please add them as a collaborator to the repository so they can be requested in the future. Non-collaborators requested: Attn Admins: Admin Instructions:
|
|
@PaddyDengKC , please refer to https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format to update the commit message. |
34bc9ad to
a6bb5b8
Compare
@lgao4 Have updated the commit message. Sorry for the inconvenience. |
a6bb5b8 to
bb24abb
Compare
This comment was marked as abuse.
This comment was marked as abuse.
bb24abb to
edd74a3
Compare
6014601 to
daf2892
Compare
|
@apop5 , are you ok with the latest code change based on your feedback? |
7161e79 to
8fe13c9
Compare
Yes, I'm okay with the latest. |
…ecSfdp
The pointer `Instance->SfdpBasicFlash` can be used before initializing.
Example code flow:
- CreateSpiNorFlashSfdpInstance: Allocate pool for `Instance`
- InitialSpiNorFlashSfdpInstance
- ReadSfdp
- ReadSfdpHeader
- FillWriteBuffer: Dereferencing
`Instance->SfdpBasicFlash`
- ReadSfdpBasicParameterTable: Allocate pool for
`Instance->SfdpBasicFlash`
Check both `Instance` and `Instance->SfdpBasicFlash` should have
a non null value before dereferencing it. Otherwise use the defaut
value 0.
Also terminate the function if `Instance` or `WriteBuffer` is NULL.
Signed-off-by: Paddy Deng <v-paddydeng@microsoft.com>
8fe13c9 to
be15dd0
Compare
Fix false positive assert added in tianocore#10924 Functon `FillWriteBuffer()` should able to accept NULL WriteBuffer when WriteBytes equals 0. Use case: ``` // Read Status register TransactionBufferLength = FillWriteBuffer ( Instance, SPI_FLASH_RDSR, SPI_FLASH_RDSR_DUMMY, SPI_FLASH_RDSR_ADDR_BYTES, FALSE, 0, 0, // WriteBytes = 0 NULL // WriteBuffer can be NULL ); ``` Signed-off-by: Paddy Deng <v-paddydeng@microsoft.com>
Fix false positive assert added in #10924 Functon `FillWriteBuffer()` should able to accept NULL WriteBuffer when WriteBytes equals 0. Use case: ``` // Read Status register TransactionBufferLength = FillWriteBuffer ( Instance, SPI_FLASH_RDSR, SPI_FLASH_RDSR_DUMMY, SPI_FLASH_RDSR_ADDR_BYTES, FALSE, 0, 0, // WriteBytes = 0 NULL // WriteBuffer can be NULL ); ``` Signed-off-by: Paddy Deng <v-paddydeng@microsoft.com>
Fix false positive assert added in tianocore#10924 Functon `FillWriteBuffer()` should able to accept NULL WriteBuffer when WriteBytes equals 0. Use case: ``` // Read Status register TransactionBufferLength = FillWriteBuffer ( Instance, SPI_FLASH_RDSR, SPI_FLASH_RDSR_DUMMY, SPI_FLASH_RDSR_ADDR_BYTES, FALSE, 0, 0, // WriteBytes = 0 NULL // WriteBuffer can be NULL ); ``` Signed-off-by: Paddy Deng <v-paddydeng@microsoft.com>
Fix false positive assert added in tianocore#10924 Functon `FillWriteBuffer()` should able to accept NULL WriteBuffer when WriteBytes equals 0. Use case: ``` // Read Status register TransactionBufferLength = FillWriteBuffer ( Instance, SPI_FLASH_RDSR, SPI_FLASH_RDSR_DUMMY, SPI_FLASH_RDSR_ADDR_BYTES, FALSE, 0, 0, // WriteBytes = 0 NULL // WriteBuffer can be NULL ); ``` Signed-off-by: Paddy Deng <v-paddydeng@microsoft.com>
Description
Instance->SfdpBasicFlashcan be used before initializing.Example code flow:
CreateSpiNorFlashSfdpInstance: Allocate pool for
InstanceInstance->SfdpBasicFlashInstance->SfdpBasicFlashBreaking change?
Impacts security?
Includes tests?
How This Was Tested
Test with NULL Detection feature enabled, an exception was fixed by this code change.
Integration Instructions
NA