[edk2-devel] [PATCH] MdeModulePkg/Bus: Potential NULL pointer on Token

GuoMinJ posted 1 patch 4 years, 2 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
[edk2-devel] [PATCH] MdeModulePkg/Bus: Potential NULL pointer on Token
Posted by GuoMinJ 4 years, 2 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2286

Token pointer may be NULL, it is should be check before use it.

Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
---
 MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
index 9f42abe7e2..25ab5abb2d 100644
--- a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
+++ b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
@@ -1367,7 +1367,12 @@ SdEraseBlocks (
     return Status;
   }
 
-  DEBUG ((EFI_D_ERROR, "SdEraseBlocks(): Lba 0x%x BlkNo 0x%x Event %p with %r\n", Lba, BlockNum, Token->Event, Status));
+  DEBUG ((DEBUG_ERROR, "SdEraseBlocks(): Lba 0x%x BlkNo 0x%x with %r, ", Lba, BlockNum, Status));
+  if ((Token != NULL) && (Token->Event != NULL)) {
+    DEBUG ((DEBUG_ERROR, "Event pointer is %p\n", Token->Event));
+  else {
+    DEBUG ((DEBUG_ERROR, "Event is meaningless\n"));
+  }
 
   return Status;
 }
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#54705): https://edk2.groups.io/g/devel/message/54705
Mute This Topic: https://groups.io/mt/71445850/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] MdeModulePkg/Bus: Potential NULL pointer on Token
Posted by Laszlo Ersek 4 years, 2 months ago
On 02/21/20 07:00, GuoMinJ wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2286
> 
> Token pointer may be NULL, it is should be check before use it.
> 
> Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
> ---
>  MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
> index 9f42abe7e2..25ab5abb2d 100644
> --- a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
> +++ b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
> @@ -1367,7 +1367,12 @@ SdEraseBlocks (
>      return Status;
>    }
>  
> -  DEBUG ((EFI_D_ERROR, "SdEraseBlocks(): Lba 0x%x BlkNo 0x%x Event %p with %r\n", Lba, BlockNum, Token->Event, Status));
> +  DEBUG ((DEBUG_ERROR, "SdEraseBlocks(): Lba 0x%x BlkNo 0x%x with %r, ", Lba, BlockNum, Status));
> +  if ((Token != NULL) && (Token->Event != NULL)) {
> +    DEBUG ((DEBUG_ERROR, "Event pointer is %p\n", Token->Event));
> +  else {
> +    DEBUG ((DEBUG_ERROR, "Event is meaningless\n"));
> +  }
>  
>    return Status;
>  }
> 

Please update the subject line; it should say "SdDxe" somewhere.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#54715): https://edk2.groups.io/g/devel/message/54715
Mute This Topic: https://groups.io/mt/71445850/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-