forked from openwrt/packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
collectd: smart: add patch to check udev_enumerate_scan_devices retur…
…n value The function udev_enumarte_scan_devices returns a value less than 0 on failure. If this is the case then we terminate the read for this smart information. This change was already send upstream. And could be delete in feature collectd versions. Signed-off-by: Florian Eckert <[email protected]>
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
utils/collectd/patches/941-Check-udev_enumerate_scan_devices-return-value.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
From 289f58c9c96d5478cf200f7a3e62b82e86b12d32 Mon Sep 17 00:00:00 2001 | ||
From: Florian Eckert <[email protected]> | ||
Date: Tue, 15 Mar 2022 14:56:19 +0100 | ||
Subject: [PATCH] Check udev_enumerate_scan_devices return value | ||
|
||
This change checks the return value of the function and cancels the call | ||
if the returned integer is not greater than or equal to 0. | ||
|
||
Signed-off-by: Florian Eckert <[email protected]> | ||
--- | ||
src/smart.c | 18 ++++++++++++++++-- | ||
1 file changed, 16 insertions(+), 2 deletions(-) | ||
|
||
--- a/src/smart.c | ||
+++ b/src/smart.c | ||
@@ -104,6 +104,7 @@ static int create_ignorelist_by_serial(i | ||
struct udev_enumerate *enumerate; | ||
struct udev_list_entry *devices, *dev_list_entry; | ||
struct udev_device *dev; | ||
+ int r; | ||
|
||
if (ignorelist_by_serial == NULL) | ||
ignorelist_by_serial = ignorelist_create(invert_ignorelist); | ||
@@ -127,7 +128,13 @@ static int create_ignorelist_by_serial(i | ||
} | ||
udev_enumerate_add_match_subsystem(enumerate, "block"); | ||
udev_enumerate_add_match_property(enumerate, "DEVTYPE", "disk"); | ||
- udev_enumerate_scan_devices(enumerate); | ||
+ | ||
+ r = udev_enumerate_scan_devices(enumerate); | ||
+ if (r < 0) { | ||
+ WARNING("smart plugin: udev scan devices failed"); | ||
+ return -1; | ||
+ } | ||
+ | ||
devices = udev_enumerate_get_list_entry(enumerate); | ||
if (devices == NULL) { | ||
ERROR("udev returned an empty list deviecs"); | ||
@@ -597,6 +604,7 @@ static int smart_read(void) { | ||
struct udev_enumerate *enumerate; | ||
struct udev_list_entry *devices, *dev_list_entry; | ||
struct udev_device *dev; | ||
+ int r; | ||
|
||
/* Use udev to get a list of disks */ | ||
handle_udev = udev_new(); | ||
@@ -611,7 +619,13 @@ static int smart_read(void) { | ||
} | ||
udev_enumerate_add_match_subsystem(enumerate, "block"); | ||
udev_enumerate_add_match_property(enumerate, "DEVTYPE", "disk"); | ||
- udev_enumerate_scan_devices(enumerate); | ||
+ | ||
+ r = udev_enumerate_scan_devices(enumerate); | ||
+ if (r < 0) { | ||
+ WARNING("smart plugin: udev scan devices failed"); | ||
+ return -1; | ||
+ } | ||
+ | ||
devices = udev_enumerate_get_list_entry(enumerate); | ||
if (devices == NULL) { | ||
ERROR("udev returned an empty list deviecs"); |