Skip to content

Commit

Permalink
Fix null pointer return in net_udp (prometheus#355)
Browse files Browse the repository at this point in the history
* fix crash seen in node_exporter

Signed-off-by: Hubert Chen <hubert@branchmetrics.io>
  • Loading branch information
hubt authored Feb 8, 2021
1 parent d561161 commit 5ce79d5
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions net_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ func (fs FS) NetUDP6() (NetUDP, error) {
// NetUDPSummary returns already computed statistics like the total queue lengths
// for UDP datagrams read from /proc/net/udp.
func (fs FS) NetUDPSummary() (*NetUDPSummary, error) {
n, err := newNetUDPSummary(fs.proc.Path("net/udp"))
n1 := NetUDPSummary(*n)
return &n1, err
return newNetUDPSummary(fs.proc.Path("net/udp"))
}

// NetUDP6Summary returns already computed statistics like the total queue lengths
// for UDP datagrams read from /proc/net/udp6.
func (fs FS) NetUDP6Summary() (*NetUDPSummary, error) {
n, err := newNetUDPSummary(fs.proc.Path("net/udp6"))
n1 := NetUDPSummary(*n)
return &n1, err
return newNetUDPSummary(fs.proc.Path("net/udp6"))
}

// newNetUDP creates a new NetUDP{,6} from the contents of the given file.
Expand Down

0 comments on commit 5ce79d5

Please sign in to comment.