-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix reported defect from coverity scan #1706
Conversation
@@ -862,7 +862,7 @@ void setup_log(struct io_log **log, struct log_params *p, | |||
l->log_ddir_mask = LOG_OFFSET_SAMPLE_BIT; | |||
if (l->log_prio) | |||
l->log_ddir_mask |= LOG_PRIO_SAMPLE_BIT; | |||
if (l->td->o.log_max == IO_LOG_SAMPLE_BOTH) | |||
if (l->td && l->td->o.log_max == IO_LOG_SAMPLE_BOTH) |
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.
This is a work-around just to appease the checker, not a huge fan. Either p->td is always valid, and in which case l->td is also always valid, or it's valid to call setup_log() with NULL p->td and checking is needed. Decide which one it is and do the fix based on that.
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.
Yes setup_log()
gets called with NULL p->td for agg-read_bw.log
, agg-write_bw.log
and agg-trim_bw.log
. So this check is required.
I think this is the reason we have the same check few lines above.
if (l->td && l->td->o.io_submit_mode != IO_MODE_OFFLOAD)
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.
Gotcha - then the fix looks fine to me. Can you add a comment as to when it's NULL?
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.
Done, please take a look.
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.
Did you push it? Don't see it.
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.
Ah my mistake, I only updated the commit message previously. Its should be done now.
6c26fa1
to
acc481b
Compare
Thanks! |
Fix the two Null pointer dereferences issue reported by Coverity scan Null pointer dereferences (FORWARD_NULL) Dereferencing null pointer "l->td" Null pointer dereferences (REVERSE_INULL) Null-checking "p->td" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. For aggregate read, write and trim bandwidth log, the setup_log function gets called with NULL pointer reference for thread data. Thus before dereferencing further we should check "l->td". Signed-off-by: Ankit Kumar <[email protected]>
Fix the two Null pointer dereferences issue reported by Coverity scan
Null pointer dereferences (FORWARD_NULL)
Dereferencing null pointer "l->td"
Null pointer dereferences (REVERSE_INULL)
Null-checking "p->td" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.