Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI 4 Wire Driver dereferencing a -1 Pointer #32

Open
burnin opened this issue Apr 1, 2023 · 1 comment
Open

SPI 4 Wire Driver dereferencing a -1 Pointer #32

burnin opened this issue Apr 1, 2023 · 1 comment

Comments

@burnin
Copy link

burnin commented Apr 1, 2023

While playing around with the library i found a small bug in the code.
I generated code for a ILI9844 display with the "LE SPI 4-Line" + "LE External Controller" Modules.
MPLabX 6.05, XC32 v4.21, GFX library v3.12.2 (Latest).

Bug:
drv_gfx_external_controller.c - DRV_ILI9488_Update() calls GFX_Disp_Intf_Open() from drv_gfx_disp_intf_spi4.c which normally returns a Pointer of type GFX_Disp_Intf.
On failure GFX_Disp_Intf_Open() returns -1.
But the DRV_ILI9488_Update() function checks for 0 (NULL) instead of -1.
Which later results in a data bus exception when the GFX_Disp_Intf_Write() function dereferences the -1 pointer.

Fix:
GFX_Disp_Intf_Open() should return 0 instead of -1 on failure which would be consistent with how invalid pointers are usually handled.

Personal opinion / coding style stuff:
The GFX_Disp_Intf type is typedef'd as a uint32_t which might be why it was confused for a handle instead of a pointer.
So maybe put a void* or uintptr_t there instead of uint32_t so it is 100% clear that this should be a pointer.

@MHGC
Copy link
Contributor

MHGC commented Jun 23, 2023

Thanks for the feedback. We will look into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants