-
Notifications
You must be signed in to change notification settings - Fork 164
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
Add missing nil check for DPC when processing wwan status update #4459
Conversation
DPC can be still nil when DPCManager receives the first status from the wwan microservice. Without nil check, processWwanStatus function may therefore hit the nil dereference panic. Another small change in this commit is to avoid redundant calls to currentDPC() - dpc is already retrieved at the beginning of the function. Signed-off-by: Milan Lenco <[email protected]>
@@ -76,14 +76,14 @@ func (m *DpcManager) processWwanStatus(ctx context.Context, status types.WwanSta | |||
} | |||
|
|||
if changed || wasInProgress { | |||
if m.currentDPC() != nil { | |||
changedDPC := m.setDiscoveredWwanIfNames(m.currentDPC()) | |||
if dpc != nil { |
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.
Trying to understand whether is line change is fixing something or just making it easier to read and follow. Is there a case where m.currentDPC() would change between line 16 and this line?
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.
According to the commit message, it's just a refactoring not to call the same function twice.
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, correct, DPCManager runs as one Go routine so m.currentDPC()
called here returns the same thing and it is redundant to call it multiple times.
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.
LGTM
DPC can be still nil when
DPCManager
receives the first status from the wwan microservice. Without the nil check,processWwanStatus
function may therefore hit the nil dereference panic.Another small change in this commit is to avoid redundant calls to
currentDPC()
- dpc is already retrieved at the beginning of the function.The issue was found during 13.4 LTS testing - it is also the only LTS version affected (the problematic if-statement was added in 12.5.0)