Skip to content

Commit b2e4cb1

Browse files
yowenterv-zhuravlev
authored andcommitted
fix hwmon nil ptr (prometheus#2873)
* fix hwmon nil ptr syslink maybe lost in some cases. --------- Signed-off-by: TaoGe <6657718+yowenter@users.noreply.github.com> Signed-off-by: Vitaly Zhuravlev <v-zhuravlev@users.noreply.github.com>
1 parent c422c5d commit b2e4cb1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

collector/hwmon_linux.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error {
446446

447447
for _, hwDir := range hwmonFiles {
448448
hwmonXPathName := filepath.Join(hwmonPathName, hwDir.Name())
449-
fileInfo, _ := os.Lstat(hwmonXPathName)
449+
fileInfo, err := os.Lstat(hwmonXPathName)
450+
if err != nil {
451+
continue
452+
}
450453

451454
if fileInfo.Mode()&os.ModeSymlink > 0 {
452455
fileInfo, err = os.Stat(hwmonXPathName)

0 commit comments

Comments
 (0)