Repository navigation
os/armino,os/board/bk7239n: Fix hang and crash paths found by static analysis in bk7239n PM, RTC and I2C #7626
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,6 +209,9 @@ static int armino_rdtime(FAR struct rtc_lowerhalf_s *lower, FAR struct rtc_time | |
| int ret; | ||
|
|
||
| DEBUGASSERT(lower != NULL && rtctime != NULL); | ||
| if (lower == NULL || rtctime == NULL) { | ||
|
Comment on lines
211
to
+212
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eunwoo-nam Do we need to keep both line 211 and line 212?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two checks are redundant, and with assertions enabled DEBUGASSERT panics before reaching -EINVAL . armino_settime() (line 255) uses only the if check. Can we drop DEBUGASSERT and keep just the if ? |
||
| return -EINVAL; | ||
| } | ||
| rtc = (FAR struct armino_lowerhalf_s *)lower; | ||
| ret = sem_wait(&rtc->devsem); | ||
| if (ret < 0) { | ||
|
|
@@ -249,6 +252,10 @@ static int armino_settime(FAR struct rtc_lowerhalf_s *lower, FAR const struct rt | |
| { | ||
| struct timespec ts; | ||
|
|
||
| if (lower == NULL || rtctime == NULL) { | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| /* Convert the struct rtc_time to a time_t. Here we assume that struct | ||
| * rtc_time is cast compatible with struct tm. | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sunghan-chang @eunwoo-nam
I'd prefer i2cerr : a NULL dev / msgs is caller misuse and we return ERROR , so error level fits. But this file defines i2cinfo as an empty macro, and i2cerr also requires CONFIG_DEBUG_I2C_ERROR to print, so neither shows by default. Would lowsyslog(LOG_ERR, ...) be acceptable instead?