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

GuoMinJ posted 1 patch 4 years, 1 month 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 v2] MdeModulePkg/SdDxe: Potential NULL pointer on Token
Posted by GuoMinJ 4 years, 1 month ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2286

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

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
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..0cc2e70b58 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 (#55377): https://edk2.groups.io/g/devel/message/55377
Mute This Topic: https://groups.io/mt/71722698/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2] MdeModulePkg/SdDxe: Potential NULL pointer on Token
Posted by Guomin Jiang 4 years ago
Hi Ray, Hao

Could you please help review this changes.

Thanks.
> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> GuoMinJ
> Sent: Wednesday, March 4, 2020 5:41 PM
> To: devel@edk2.groups.io
> Cc: GuoMinJ <newexplorerj@gmail.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: [edk2-devel] [PATCH v2] MdeModulePkg/SdDxe: Potential NULL
> pointer on Token
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2286
> 
> Token pointer may be NULL, it is should be check before use it.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> 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..0cc2e70b58 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 (#56360): https://edk2.groups.io/g/devel/message/56360
Mute This Topic: https://groups.io/mt/71722698/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2] MdeModulePkg/SdDxe: Potential NULL pointer on Token
Posted by Wu, Hao A 4 years ago
> -----Original Message-----
> From: Jiang, Guomin
> Sent: Thursday, March 26, 2020 1:57 PM
> To: devel@edk2.groups.io; newexplorerj@gmail.com
> Cc: Wu, Hao A; Ni, Ray
> Subject: RE: [edk2-devel] [PATCH v2] MdeModulePkg/SdDxe: Potential NULL
> pointer on Token
> 
> Hi Ray, Hao
> 
> Could you please help review this changes.


Really sorry for missing this patch.

Could you help to follow the codes in function EmmcEraseBlocks() under file:
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c
for the fix in SdDxe? Thanks.

Best Regards,
Hao Wu


> 
> Thanks.
> > -----Original Message-----
> > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> > GuoMinJ
> > Sent: Wednesday, March 4, 2020 5:41 PM
> > To: devel@edk2.groups.io
> > Cc: GuoMinJ <newexplorerj@gmail.com>; Wu, Hao A
> > <hao.a.wu@intel.com>; Ni, Ray <ray.ni@intel.com>
> > Subject: [edk2-devel] [PATCH v2] MdeModulePkg/SdDxe: Potential NULL
> > pointer on Token
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2286
> >
> > Token pointer may be NULL, it is should be check before use it.
> >
> > Cc: Hao A Wu <hao.a.wu@intel.com>
> > Cc: Ray Ni <ray.ni@intel.com>
> > 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..0cc2e70b58 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 (#56361): https://edk2.groups.io/g/devel/message/56361
Mute This Topic: https://groups.io/mt/71722698/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-