From nobody Thu Dec 26 13:05:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1506456955777413.2891198182675; Tue, 26 Sep 2017 13:15:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 832E321EC8D19; Tue, 26 Sep 2017 13:12:29 -0700 (PDT) Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3F22B21EC8D19 for ; Tue, 26 Sep 2017 13:12:25 -0700 (PDT) Received: from E111747.Emea.Arm.com (e111747.emea.arm.com [10.1.27.40]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v8QKFY5T017392; Tue, 26 Sep 2017 21:15:35 +0100 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.96.140; helo=cam-smtp0.cambridge.arm.com; envelope-from=evan.lloyd@arm.com; receiver=edk2-devel@lists.01.org From: evan.lloyd@arm.com To: edk2-devel@lists.01.org Date: Tue, 26 Sep 2017 21:15:14 +0100 Message-Id: <20170926201529.11644-5-evan.lloyd@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170926201529.11644-1-evan.lloyd@arm.com> References: <20170926201529.11644-1-evan.lloyd@arm.com> Subject: [edk2] [PATCH 04/19] ArmPlatformPkg: LcdGraphicsOurputDxe: Add debug asserts X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "ard.biesheuvel@linaro.org"@arm.com, "leif.lindholm@linaro.org"@arm.com, "nd@arm.com"@arm.com, "Matteo.Carlini@arm.com"@arm.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Girish Pathak This change adds some debug assertions e.g to catch NULL pointer errors missing in PL11Lcd and HdLcd modules. This change also improves related error handling code. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Girish Pathak Signed-off-by: Evan Lloyd --- ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVExpress= .c | 44 ++++++++++++++++++-- ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111LcdArmVE= xpress.c | 43 ++++++++++++++++++- ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c = | 8 ++-- ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c = | 8 ++-- 4 files changed, 90 insertions(+), 13 deletions(-) diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLc= dArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/= HdLcdArmVExpress.c index b9859a56988f7e5be0adbaa49048a683fe586bfe..58dd9f0c77e1bc9af559a71d0c7= cce72d71c6da5 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx= press.c +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/HdLcdArmVExpressLib/HdLcdArmVEx= press.c @@ -140,6 +140,7 @@ LcdPlatformInitializeDisplay ( * buffer in bytes * * @retval EFI_SUCCESS Frame buffer memory allocation success. + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize are NULL. * @retval !(EFI_SUCCESS) Other errors. **/ EFI_STATUS @@ -151,6 +152,13 @@ LcdPlatformGetVram ( EFI_STATUS Status; EFI_ALLOCATE_TYPE AllocationType; =20 + // Check VramBaseAddress and VramSize are not NULL. + if (VramBaseAddress =3D=3D NULL || VramSize =3D=3D NULL) { + ASSERT (VramBaseAddress !=3D NULL); + ASSERT (VramSize !=3D NULL); + return EFI_INVALID_PARAMETER; + } + // Set the vram size *VramSize =3D LCD_VRAM_SIZE; =20 @@ -169,6 +177,7 @@ LcdPlatformGetVram ( VramBaseAddress ); if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); return Status; } =20 @@ -179,8 +188,8 @@ LcdPlatformGetVram ( *VramSize, EFI_MEMORY_WC ); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize)); return Status; } @@ -215,6 +224,7 @@ LcdPlatformSetMode ( EFI_STATUS Status; =20 if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); return EFI_INVALID_PARAMETER; } =20 @@ -264,6 +274,7 @@ LcdPlatformSetMode ( * * @retval EFI_SUCCESS Success if the requested mode is found. * @retval EFI_INVALID_PARAMETER Requested mode not found. + * @retval EFI_INVALID_PARAMETER Info is NULL. **/ EFI_STATUS LcdPlatformQueryMode ( @@ -271,7 +282,9 @@ LcdPlatformQueryMode ( OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info ) { - if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + if (ModeNumber >=3D LcdPlatformGetMaxMode () || Info =3D=3D NULL) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); + ASSERT (Info !=3D NULL); return EFI_INVALID_PARAMETER; } =20 @@ -334,6 +347,28 @@ LcdPlatformGetTimings ( ) { if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); + return EFI_INVALID_PARAMETER; + } + + if (HRes =3D=3D NULL + || HSync =3D=3D NULL + || HBackPorch =3D=3D NULL + || HFrontPorch =3D=3D NULL + || VRes =3D=3D NULL + || VSync =3D=3D NULL + || VBackPorch =3D=3D NULL + || VFrontPorch =3D=3D NULL) + { + // One of the pointers is NULL + ASSERT (HRes !=3D NULL); + ASSERT (HSync !=3D NULL); + ASSERT (HBackPorch !=3D NULL); + ASSERT (HFrontPorch !=3D NULL); + ASSERT (VRes !=3D NULL); + ASSERT (VSync !=3D NULL); + ASSERT (VBackPorch !=3D NULL); + ASSERT (VFrontPorch !=3D NULL); return EFI_INVALID_PARAMETER; } =20 @@ -356,6 +391,7 @@ LcdPlatformGetTimings ( * * @retval EFI_SUCCESS The requested mode is found. * @retval EFI_INVALID_PARAMETER Requested mode not found. + * @retval EFI_INVALID_PARAMETER Bpp is NULL. **/ EFI_STATUS LcdPlatformGetBpp ( @@ -363,7 +399,9 @@ LcdPlatformGetBpp ( OUT LCD_BPP * CONST Bpp ) { - if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + if (ModeNumber >=3D LcdPlatformGetMaxMode () || Bpp =3D=3D NULL) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); + ASSERT (Bpp !=3D NULL); return EFI_INVALID_PARAMETER; } =20 diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/P= L111LcdArmVExpress.c b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVEx= pressLib/PL111LcdArmVExpress.c index 6ae13f06d8b396ea1c67f0bcd735a9d70f476400..5a4abd4c6f9e84d3d690af7233c= 1cebfe1ad339b 100644 --- a/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd= ArmVExpress.c +++ b/ArmPlatformPkg/ArmVExpressPkg/Library/PL111LcdArmVExpressLib/PL111Lcd= ArmVExpress.c @@ -191,6 +191,7 @@ LcdPlatformInitializeDisplay ( * buffer in bytes * * @retval EFI_SUCCESS Frame buffer memory allocation success. + * @retval EFI_INVALID_PARAMETER VramBaseAddress or VramSize is NULL. * @retval !(EFI_SUCCESS) Other errors. **/ EFI_STATUS @@ -203,6 +204,13 @@ LcdPlatformGetVram ( =20 Status =3D EFI_SUCCESS; =20 + // Check VramBaseAddress and VramSize are not NULL. + if (VramBaseAddress =3D=3D NULL || VramSize =3D=3D NULL) { + ASSERT (VramBaseAddress !=3D NULL); + ASSERT (VramSize !=3D NULL); + return EFI_INVALID_PARAMETER; + } + // Is it on the motherboard or on the daughterboard? switch (PL111_CLCD_SITE) { =20 @@ -223,6 +231,7 @@ LcdPlatformGetVram ( VramBaseAddress ); if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); return Status; } =20 @@ -233,8 +242,8 @@ LcdPlatformGetVram ( *VramSize, EFI_MEMORY_WC ); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); gBS->FreePages (*VramBaseAddress, EFI_SIZE_TO_PAGES (*VramSize)); return Status; } @@ -293,6 +302,7 @@ LcdPlatformSetMode ( UINT32 SysId; =20 if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); return EFI_INVALID_PARAMETER; } =20 @@ -359,6 +369,7 @@ LcdPlatformSetMode ( * (on success). * * @retval EFI_SUCCESS Success if the requested mode is found. + * @retval EFI_INVALID_PARAMETER Info is NULL. * @retval EFI_INVALID_PARAMETER Requested mode not found. **/ EFI_STATUS @@ -367,7 +378,9 @@ LcdPlatformQueryMode ( OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * CONST Info ) { - if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + if (ModeNumber >=3D LcdPlatformGetMaxMode () || Info =3D=3D NULL) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); + ASSERT (Info !=3D NULL); return EFI_INVALID_PARAMETER; } =20 @@ -415,6 +428,7 @@ LcdPlatformQueryMode ( * * @retval EFI_SUCCESS Success if the requested mode is found. * @retval EFI_INVALID_PARAMETER Requested mode not found. + * @retval EFI_INVALID_PARAMETER One of the OUT parameters is NULL. **/ EFI_STATUS LcdPlatformGetTimings ( @@ -430,6 +444,28 @@ LcdPlatformGetTimings ( ) { if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); + return EFI_INVALID_PARAMETER; + } + + if (HRes =3D=3D NULL + || HSync =3D=3D NULL + || HBackPorch =3D=3D NULL + || HFrontPorch =3D=3D NULL + || VRes =3D=3D NULL + || VSync =3D=3D NULL + || VBackPorch =3D=3D NULL + || VFrontPorch =3D=3D NULL) + { + // One of the pointers is NULL + ASSERT (HRes !=3D NULL); + ASSERT (HSync !=3D NULL); + ASSERT (HBackPorch !=3D NULL); + ASSERT (HFrontPorch !=3D NULL); + ASSERT (VRes !=3D NULL); + ASSERT (VSync !=3D NULL); + ASSERT (VBackPorch !=3D NULL); + ASSERT (VFrontPorch !=3D NULL); return EFI_INVALID_PARAMETER; } =20 @@ -452,6 +488,7 @@ LcdPlatformGetTimings ( * * @retval EFI_SUCCESS The requested mode is found. * @retval EFI_INVALID_PARAMETER Requested mode not found. + * @retval EFI_INVALID_PARAMETER Bpp is NULL. **/ EFI_STATUS LcdPlatformGetBpp ( @@ -460,6 +497,8 @@ LcdPlatformGetBpp ( ) { if (ModeNumber >=3D LcdPlatformGetMaxMode ()) { + ASSERT (ModeNumber < LcdPlatformGetMaxMode ()); + ASSERT (Bpp !=3D NULL); return EFI_INVALID_PARAMETER; } =20 diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c b/ArmPlatf= ormPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c index 5f950579720fb69e0a481f697a5cc4038158b409..a266671a26f01d31e8ddb0cf7cb= fe59d2f4dc49c 100644 --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/HdLcd.c @@ -109,15 +109,15 @@ LcdSetMode ( &VBackPorch, &VFrontPorch ); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + ASSERT_EFI_ERROR (Status); + return Status; } =20 Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + ASSERT_EFI_ERROR (Status); + return Status; } =20 BytesPerPixel =3D GetBytesPerPixel (LcdBpp); diff --git a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c b/ArmPl= atformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c index 386e6140a69b045f77ee7fa60c4587d8bf4e7d54..f432c8d802614e8a0e4ddab3898= f6e0dbf9a1572 100644 --- a/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c +++ b/ArmPlatformPkg/Drivers/LcdGraphicsOutputDxe/PL111Lcd.c @@ -110,15 +110,15 @@ LcdSetMode ( &VBackPorch, &VFrontPorch ); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + ASSERT_EFI_ERROR (Status); + return Status; } =20 Status =3D LcdPlatformGetBpp (ModeNumber, &LcdBpp); - ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - return EFI_DEVICE_ERROR; + ASSERT_EFI_ERROR (Status); + return Status; } =20 // Disable the CLCD_LcdEn bit --=20 Guid("CE165669-3EF3-493F-B85D-6190EE5B9759") _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel