Skip to content

Fix nil pointer dereference panic in sidecar mounter#1285

Open
alleaditya wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
alleaditya:fix_nil_pointer_dereference
Open

Fix nil pointer dereference panic in sidecar mounter#1285
alleaditya wants to merge 2 commits intoGoogleCloudPlatform:mainfrom
alleaditya:fix_nil_pointer_dereference

Conversation

@alleaditya
Copy link
Copy Markdown
Contributor

@alleaditya alleaditya commented Apr 1, 2026

What type of PR is this?
/kind bug

What this PR does / why we need it:
This PR fixes a nil pointer dereference panic in the gke-gcsfuse-sidecar container. The panic occurs at cmd/sidecar_mounter/main.go:86 when mc (MountConfig) is accessed immediately after NewMountConfig without checking if it is nil. The fix adds a nil check to ensure safe execution.

Which issue(s) this PR fixes:
Fixes (Internal Bug b/498411736)

Special notes for your reviewer:
https://b.corp.google.com/issues/498411736

Does this PR introduce a user-facing change?:

NONE

@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alleaditya

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a nil check for the MountConfig object in cmd/sidecar_mounter/main.go to prevent potential panics when the configuration fails to initialize. The review feedback points out that while this addition is correct, it makes a subsequent check on the same object redundant, suggesting further cleanup to improve code clarity.

Comment thread cmd/sidecar_mounter/main.go
time.Sleep(1500 * time.Millisecond)
mc := sidecarmounter.NewMountConfig(sp, flagsFromDriver)
if mc == nil {
klog.Errorf("failed to create mount config for %s", sp)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we write this error to the error file so node publish can report it to the customer? Otherwise I'm not sure what would happen if you just skip the mount, requires a small repro to find out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants