diff options
author | Tom Gundersen <teg@jklm.no> | 2015-06-23 17:16:28 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-06-23 17:20:12 +0200 |
commit | 56b13bcc992f296a061d9ae39d9369a8427bca73 (patch) | |
tree | 7623b5f08542760d6167b0d51b02d0fdfe55ddcc /src/udev/udevadm-trigger.c | |
parent | udev: worker - check return value of udev_monitor_enable_receiving() (diff) | |
download | systemd-56b13bcc992f296a061d9ae39d9369a8427bca73.tar.xz systemd-56b13bcc992f296a061d9ae39d9369a8427bca73.zip |
udevadm: trigger - check return values
Fixes CID#1296243.
Diffstat (limited to '')
-rw-r--r-- | src/udev/udevadm-trigger.c | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 11e83f355f..7af9665f8a 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -116,7 +116,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { } device_type = TYPE_DEVICES; const char *action = "change"; _cleanup_udev_enumerate_unref_ struct udev_enumerate *udev_enumerate = NULL; - int c; + int c, r; udev_enumerate = udev_enumerate_new(udev); if (udev_enumerate == NULL) @@ -153,28 +153,56 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { break; case 's': - udev_enumerate_add_match_subsystem(udev_enumerate, optarg); + r = udev_enumerate_add_match_subsystem(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add subsystem match '%s': %m", optarg); + return 2; + } break; case 'S': - udev_enumerate_add_nomatch_subsystem(udev_enumerate, optarg); + r = udev_enumerate_add_nomatch_subsystem(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add negative subsystem match '%s': %m", optarg); + return 2; + } break; case 'a': key = keyval(optarg, &val, buf, sizeof(buf)); - udev_enumerate_add_match_sysattr(udev_enumerate, key, val); + r = udev_enumerate_add_match_sysattr(udev_enumerate, key, val); + if (r < 0) { + log_error_errno(r, "could not add sysattr match '%s=%s': %m", key, val); + return 2; + } break; case 'A': key = keyval(optarg, &val, buf, sizeof(buf)); - udev_enumerate_add_nomatch_sysattr(udev_enumerate, key, val); + r = udev_enumerate_add_nomatch_sysattr(udev_enumerate, key, val); + if (r < 0) { + log_error_errno(r, "could not add negative sysattr match '%s=%s': %m", key, val); + return 2; + } break; case 'p': key = keyval(optarg, &val, buf, sizeof(buf)); - udev_enumerate_add_match_property(udev_enumerate, key, val); + r = udev_enumerate_add_match_property(udev_enumerate, key, val); + if (r < 0) { + log_error_errno(r, "could not add property match '%s=%s': %m", key, val); + return 2; + } break; case 'g': - udev_enumerate_add_match_tag(udev_enumerate, optarg); + r = udev_enumerate_add_match_tag(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add tag match '%s': %m", optarg); + return 2; + } break; case 'y': - udev_enumerate_add_match_sysname(udev_enumerate, optarg); + r = udev_enumerate_add_match_sysname(udev_enumerate, optarg); + if (r < 0) { + log_error_errno(r, "could not add sysname match '%s': %m", optarg); + return 2; + } break; case 'b': { _cleanup_udev_device_unref_ struct udev_device *dev; @@ -185,7 +213,11 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { return 2; } - udev_enumerate_add_match_parent(udev_enumerate, dev); + r = udev_enumerate_add_match_parent(udev_enumerate, dev); + if (r < 0) { + log_error_errno(r, "could not add parent match '%s': %m", optarg); + return 2; + } break; } @@ -198,7 +230,11 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { return 2; } - udev_enumerate_add_match_parent(udev_enumerate, dev); + r = udev_enumerate_add_match_parent(udev_enumerate, dev); + if (r < 0) { + log_error_errno(r, "could not add parent match '%s': %m", optarg); + return 2; + } break; } @@ -221,7 +257,11 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) { return 2; } - udev_enumerate_add_match_parent(udev_enumerate, dev); + r = udev_enumerate_add_match_parent(udev_enumerate, dev); + if (r < 0) { + log_error_errno(r, "could not add tag match '%s': %m", optarg); + return 2; + } } switch (device_type) { |