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 DDA8C9411A2 for ; Tue, 7 Nov 2023 05:39:05 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ZCvhXpyRpGCCqo+neBdvbxH6FjstILW7FkeUD1UDReo=; 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=1699335544; v=1; b=xAIkl0xMVMg3MFIL+AzVv5F4mTSTT6in6bS5hCpCN7/bM1D4SqpSpPatuRub5JUM+uG6JCAU tSy1kb/7dc3C9Bjrv/fdNph/CLOH3hGF+C6r33xCvd+sSMcF98CrsZMuX9GP3fG+R8cYgbao1lM piZBI7IATLF4ZRR3hOEA9u5c= X-Received: by 127.0.0.2 with SMTP id uGcTYY7687511xRDRIdugLGp; Mon, 06 Nov 2023 21:39:04 -0800 X-Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by mx.groups.io with SMTP id smtpd.web11.4243.1699335543923693295 for ; Mon, 06 Nov 2023 21:39:04 -0800 X-Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-7a6774da682so226803439f.3 for ; Mon, 06 Nov 2023 21:39:03 -0800 (PST) X-Gm-Message-State: BPGzJcdM0pwjsIdjXzZyqyKlx7686176AA= X-Google-Smtp-Source: AGHT+IFW8BMRz5LPjOTw1Ssp1cd5dfsutUaGvpBTRQJy3gwCeGWAjjmyOyoG0tVLXvxcmR7eoKdhnA== X-Received: by 2002:a05:6e02:1c22:b0:359:4e76:fbf4 with SMTP id m2-20020a056e021c2200b003594e76fbf4mr2271744ilh.13.1699335542918; Mon, 06 Nov 2023 21:39:02 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id r5-20020a92c5a5000000b00357ff86c542sm2953080ilt.4.2023.11.06.21.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 21:39:02 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli , Laszlo Ersek Subject: [edk2-devel] [PATCH v3 1/2] MdeModulePkg/Bus/Usb/UsbMouseDxe: Fix REVERSE_INULL Coverity issue Date: Tue, 7 Nov 2023 11:08:52 +0530 Message-Id: <20231107053853.76448-2-rsingh@ventanamicro.com> In-Reply-To: <20231107053853.76448-1-rsingh@ventanamicro.com> References: <20231107053853.76448-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=xAIkl0xM; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh Reviewed-by: Laszlo Ersek --- MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c b/MdeModulePkg/Bus= /Usb/UsbMouseDxe/UsbMouse.c index 451d4b934f4c..67072d476196 100644 --- a/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c +++ b/MdeModulePkg/Bus/Usb/UsbMouseDxe/UsbMouse.c @@ -160,7 +160,10 @@ USBMouseDriverBindingStart ( }=0D =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 (#110803): https://edk2.groups.io/g/devel/message/110803 Mute This Topic: https://groups.io/mt/102437986/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-