drivers: rtc: stm32: check for NULL pointer
Check for NULL rtc_time pointer in get_time() function. Signed-off-by: Abderrahmane Jarmouni <abderrahmane.jarmouni-ext@st.com>
This commit is contained in:
parent
0a60adc333
commit
0398b2a3d9
1 changed files with 7 additions and 2 deletions
|
@ -253,7 +253,12 @@ static int rtc_stm32_get_time(const struct device *dev, struct rtc_time *timeptr
|
||||||
#if HW_SUBSECOND_SUPPORT
|
#if HW_SUBSECOND_SUPPORT
|
||||||
const struct rtc_stm32_config *cfg = dev->config;
|
const struct rtc_stm32_config *cfg = dev->config;
|
||||||
uint32_t rtc_subsecond;
|
uint32_t rtc_subsecond;
|
||||||
#endif
|
#endif /* HW_SUBSECOND_SUPPORT */
|
||||||
|
|
||||||
|
if (timeptr == NULL) {
|
||||||
|
LOG_ERR("NULL rtc_time pointer");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
int err = k_mutex_lock(&data->lock, K_NO_WAIT);
|
int err = k_mutex_lock(&data->lock, K_NO_WAIT);
|
||||||
|
|
||||||
|
@ -282,7 +287,7 @@ static int rtc_stm32_get_time(const struct device *dev, struct rtc_time *timeptr
|
||||||
rtc_time = LL_RTC_TIME_Get(RTC);
|
rtc_time = LL_RTC_TIME_Get(RTC);
|
||||||
#if HW_SUBSECOND_SUPPORT
|
#if HW_SUBSECOND_SUPPORT
|
||||||
rtc_subsecond = LL_RTC_TIME_GetSubSecond(RTC);
|
rtc_subsecond = LL_RTC_TIME_GetSubSecond(RTC);
|
||||||
#endif
|
#endif /* HW_SUBSECOND_SUPPORT */
|
||||||
} while (rtc_time != LL_RTC_TIME_Get(RTC));
|
} while (rtc_time != LL_RTC_TIME_Get(RTC));
|
||||||
} while (rtc_date != LL_RTC_DATE_Get(RTC));
|
} while (rtc_date != LL_RTC_DATE_Get(RTC));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue