[edk2-devel] [PATCH] MdeModulePkg/Bus/Usb/UsbMouseDxe: Fix REVERSE_INULL Coverity issue

Ranbir Singh via groups.io posted 1 patch 1 year, 4 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c | 4 ++++
1 file changed, 4 insertions(+)
[edk2-devel] [PATCH] MdeModulePkg/Bus/Usb/UsbMouseDxe: Fix REVERSE_INULL Coverity issue
Posted by Ranbir Singh via groups.io 1 year, 4 months ago
The function USBMouseDriverBindingStart do have

ASSERT (UsbMouseDevice != NULL);

after AllocateZeroPool, but it is applicable only in DEBUG mode.
In RELEASE mode, the code proceeds to dereference "UsbMouseDevice"
which will lead to CRASH.

Hence, for safety add NULL pointer checks always. The ASSERT may be
retained or it may be deleted whatever is deemed more appropriate.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4222
Signed-off-by: Ranbir Singh <Ranbir.Singh3@Dell.com>
---
MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
index 451d4b934f..621d09713b 100644
--- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
+++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c
@@ -161,6 +161,10 @@ USBMouseDriverBindingStart (

UsbMouseDevice = AllocateZeroPool (sizeof (USB_MOUSE_DEV));
ASSERT (UsbMouseDevice != NULL);
+  if (UsbMouseDevice == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto ErrorExit;
+  }

UsbMouseDevice->UsbIo     = UsbIo;
UsbMouseDevice->Signature = USB_MOUSE_DEV_SIGNATURE;
--
2.36.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97924): https://edk2.groups.io/g/devel/message/97924
Mute This Topic: https://groups.io/mt/96046883/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-