Check for NULL ptr in HAL_PAL

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

Check for NULL ptr in HAL_PAL

Post by faisal »

The PAL driver dereferences a pointer to a peripheral address (i.e. GPIOA->ODR). The 'port' pointer should be checked for a NULL pointer using chDbgCheck() (so that it can be disabled for release builds).
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Check for NULL ptr in HAL_PAL

Post by Giovanni »

Hi,

Where exactly?

Giovanni
faisal
Posts: 382
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 45 times
Been thanked: 62 times

Re: Check for NULL ptr in HAL_PAL

Post by faisal »

The dereferencing is done mainly in the hal_pal_lld.h macro. I'm thinking we could do a null ptr check at the hal_pal layer before calling the LLD driver routines/macros.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Check for NULL ptr in HAL_PAL

Post by Giovanni »

bump

A point, the "port" parameter is not necessarily a pointer, it is dependent on architecture, this should be performed in the various LLDs.

Giovanni
Post Reply