From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D83BBD8046F for ; Wed, 4 Oct 2023 05:48:26 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=PI8+6B9Vjr3N5BpmFJgVZgo8hB3KfCH4tuV1jjLiaC4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1696398505; v=1; b=iWkSSMdmfehy66xLvF6g4TGMOh3P5od7ZJ4Lt5MQl+r0cO68FH9qY9JMsacv3HNxYur1jbGb xqxV8NcdSKaQFCu8da4OmPhZ71pDet7j4uCnMkNPKVKqSvl+Cr4v1UtHfg5pu8meZGSUzAeooh1 TIrH54MPYt6IZFfG4itBTG0Q= X-Received: by 127.0.0.2 with SMTP id PgV7YY7687511xmboNeo43x3; Tue, 03 Oct 2023 22:48:25 -0700 X-Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mx.groups.io with SMTP id smtpd.web10.12210.1696398505061035225 for ; Tue, 03 Oct 2023 22:48:25 -0700 X-Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-69101d33315so1420974b3a.3 for ; Tue, 03 Oct 2023 22:48:25 -0700 (PDT) X-Gm-Message-State: 4ElHhiYhTwhutF8HTVRTV4QLx7686176AA= X-Google-Smtp-Source: AGHT+IFpeGX8uMrej73YvanU1sfo0lB7fRwPkO30TG2mEVXAb+/Gvv23aDvi+zzR3BDn+QZdSt6KVw== X-Received: by 2002:a05:6a20:12c9:b0:142:aced:c643 with SMTP id v9-20020a056a2012c900b00142acedc643mr1622164pzg.31.1696398504403; Tue, 03 Oct 2023 22:48:24 -0700 (PDT) X-Received: from user-Latitude-5420.. ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id l12-20020a170903244c00b001c0bf60ba5csm2668777pls.272.2023.10.03.22.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 22:48:23 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Hao A Wu , Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 1/2] MdeModulePkg/Bus/Usb/UsbMouseDxe: Fix REVERSE_INULL Coverity issue Date: Wed, 4 Oct 2023 11:18:17 +0530 Message-Id: <20231004054818.100353-2-rsingh@ventanamicro.com> In-Reply-To: <20231004054818.100353-1-rsingh@ventanamicro.com> References: <20231004054818.100353-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=iWkSSMdm; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none From: Ranbir Singh The function USBMouseDriverBindingStart do have ASSERT (UsbMouseDevice !=3D NULL); after AllocateZeroPool, but it is applicable only in DEBUG mode. In RELEASE mode, if for whatever reasons UsbMouseDevice is NULL at this point, the code proceeds to dereference "UsbMouseDevice" afterwards which will lead to CRASH. Hence, for safety add NULL pointer checks always. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4222 Cc: Hao A Wu Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- 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 451d4b934f4c..621d09713b24 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c +++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c @@ -161,6 +161,10 @@ USBMouseDriverBindingStart ( =0D UsbMouseDevice =3D AllocateZeroPool (sizeof (USB_MOUSE_DEV));=0D ASSERT (UsbMouseDevice !=3D NULL);=0D + if (UsbMouseDevice =3D=3D NULL) {=0D + Status =3D EFI_OUT_OF_RESOURCES;=0D + goto ErrorExit;=0D + }=0D =0D UsbMouseDevice->UsbIo =3D UsbIo;=0D UsbMouseDevice->Signature =3D USB_MOUSE_DEV_SIGNATURE;=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109308): https://edk2.groups.io/g/devel/message/109308 Mute This Topic: https://groups.io/mt/101750273/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-