Skip to content
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

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

milan-zededa
Copy link
Contributor

@milan-zededa milan-zededa commented Dec 4, 2024

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)

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]>
@milan-zededa milan-zededa added bug Something isn't working stable Should be backported to stable release(s) labels Dec 4, 2024
@@ -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 {
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@uncleDecart uncleDecart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@milan-zededa milan-zededa merged commit a984bcb into lf-edge:master Dec 5, 2024
75 of 89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stable Should be backported to stable release(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants